mardi 15 mars 2016

Split function not being recognised

I'm trying to randomly shuffle an input retrieved from database. So far I'm able to add the retrieved value to the list. Because i want to the shuffle them, I'm trying to split the word into individual letters..Like ['l','i','s','t'] for eg. But the split function doesn't work. Where am I going wrong?

<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="java.lang.*"%>
<%
String vlemail=request.getParameter("lemail");
try
{
String str="jdbc:mysql://localhost:3306/user";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=null;
con=DriverManager.getConnection(str,"root","");
Statement st=con.createStatement(); 
ResultSet rs =st.executeQuery("select pwd from utable where email='"+vlemail+"'");
ArrayList<String> list=new ArrayList();
while(rs.next())
{

list.add(rs.getString("pwd"));
out.println(list);
List splitlist=list.split("(?!^)");
Collections.shuffle(splitlist);
out.println(splitlist);
}
out.println("Retrieved" );
}
catch(Exception e)
{
out.println(e);
out.println("Not retrieved");
}
%>




Aucun commentaire:

Enregistrer un commentaire