import java.sql.*;
class SQLQuery
{
public static void main(String arg[])
{
Connection conn = null;
Statement stmt = null;System.out.println("SQLQuery PJava for SL-5000/5500");
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e)
{
System.err.println(
"could not locate driver");
return;
}
try
{
conn = DriverManager.getConnection(
"jdbc:mysql://localhost/mysql?user=root&password=");
stmt = conn.createStatement();
}
catch ( Exception e)
{
System.err.println(e);
return;
}
try
{
String query = "select User from user";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
System.out.println(rs.getString(1));
}
catch (Exception e) { e.printStackTrace(); }
finally
{
try { stmt.close(); }
catch( Exception e ) {}try { conn.close(); }
catch( Exception e ) {}
} // end finally clause
}
}