Hello all,
I'm sorry if this is an easy fix, but I've searched everywhere and spent 3 days on this and would like my life back. I'm trying to Select data from a database using a PreparedStatement and it isn't working for me. No errors, just no data. I can Insert, Update, Delete data and I can create and drop tables. It seems the only thing I cannot do is Select from a database. I've created several new databases to make sure I didn't screw it up and still the same result. My code is quite basic, but I'll post it in case I'm missing something. I changed my query to the most basic select I could think of and still got nothing. Thanks for any help guys.
public static Connection connectToMYSQLDBMS () throws SQLException
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception x)
{
System.out.println( "Unable to load the driver class!" );
}
Connection conn = null;
try
{
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?" +
"user=user&password=password");
}
catch(SQLException e)
{
System.out.println("Unable to establish a connection..." + e);
}
return conn;
}
public static ResultSet getSongByUser(int inUserID, Connection con)
{
ResultSet srs = null;
try
{
String sqlQuery = "select * from audiotracks ";
PreparedStatement ps = con.prepareStatement(sqlQuery);
srs = ps.executeQuery();
System.out.println(srs.getFetchSize());
ps.close();
}
catch (SQLException e)
{
System.out.println("Unable to execute query... " + e );
}
return srs;
}