Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Mysql bad supported on java

FaenrFaenr Member Posts: 1
import java.sql.*;

class Retrieve
{
public static void main (String args[])
{
try
{
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
System.out.println("Mysql device driver does not exist");
System.exit(1);
}
Connection conn = DriverManager.getConnection("jdbc:mysql://0.0.0.0:0/users_table?user=user&password=password");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select username, password from users");
while (rset.next())
{
System.out.println(rset.getString(1)+" "+rset.getString(2));
}
rset.close();
stmt.close();
conn.close();
}
catch (SQLException e)
{
System.out.println("error accesing DataBase");
System.out.println("error code is: "+e.getErrorCode());
System.out.println("error message is: "+e.getMessage());
}
}
}

Seems perfect, but have something wrong, "Class.forName("com.mysql.jdbc.Driver");" it doesn't find this Class...simple to fix assigning the classpath in the autoexec, but this program isn't just for me, so how can i make it find the class everytime someone install it?
Sign In or Register to comment.