I have a string array which holds the name of 500 stocks. Now i have a table in my mysql database which holds the symbol for more than 1000 stocks alonwith their name. What i would like to do is retrieve the symbol of those 500 stocks from the table i have. I have tried the following code
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql//localhost/mydatabase","user","pass");
PreparedStatement stmt = conn.prepareStatement("SELECT (NAME) FROM stocks1 WHERE FULLNAME =?");
for(int i1=0;i1<i;i1++)
{
stmt.setString(1, name[i1]);
stmt.addBatch();
}
ResultSet t=stmt.executeQuery();
while(t.next())
System.out.println(t.getString("NAME"));
But it doesnt work. Nothing is printed. I think i am making a mistake in stmt.addBatch(). Also if i wanted the name[i1] to be follwed by a wildcard charcter(%) how would i do this.