I am a new one in database area. Hopefully someone can help me or give me
clue to solve the problem.
I have already run mySql in c:\winnt\System32\cmd.exe, and create a database
(table test1)
in c:\mysql\data\test directory. The classpath I setup in control system
environment, C:\jdk1.3.0_02; c:\jdbc\mm.mysql.jdbc-1.2c\mysql_comp.jar;
c:\jdbc\mm.mysql.jdbc-1.2c\mysql_uncomp.jar;
I try to test a simple java code with JBuilder, it doesn't work.
The code:
import java.sql.*;
public class TestQuery {
public TestQuery() {
}
public static void main(String args[])
{
String
url=("jdbc:mysql://localhost/test?user=pannyx&password=654321");
Connection con;
String query = ("select * from test1;");
Statement stmt;
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
System.out.println("ok");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("classnot fund exception: "+e.getMessage());
}
catch(Exception ex)
{
System.err.println("other exception: "+ex.getMessage());
}
try
{
System.out.println("Try to connect...");
con = DriverManager.getConnection(url, "pennyx", "654321");
System.out.println("Connect!");
stmt = con.createStatement();
ResultSet result = stmt.executeQuery(query);
while (result.next())
{
String name=result.getString(1)+ " " + result.getString(2);
System.out.println(name);
}
stmt.close();
con.close();
}
catch(SQLException ex)
{
System.out.println("SQLEXCEPTION:" + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
}
I got the following message:
C:\Program Files\jdk1.3\bin\javaw -classpath "C:\Documents and
Settings\pennyx.ALNMEL\jbproject\untitled7\classes;C:\Program
Files\jdk1.3\demo\jfc\Java2D\Java2Demo.jar;C:\Program
Files\jdk1.3\jre\lib\i18n.jar;C:\Program
Files\jdk1.3\jre\lib\jaws.jar;C:\Program
Files\jdk1.3\jre\lib\rt.jar;C:\Program
Files\jdk1.3\jre\lib\sunrsasign.jar;C:\Program
Files\jdk1.3\lib\dt.jar;C:\Program Files\jdk1.3\lib\tools.jar" -Xdebug
-Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_shmem,address=javadebug,suspend=y TestQuery
Java HotSpot(TM) Client VM warning: Setting of property "java.compiler" is
ignored
ok
Try to connect...
java.lang.InstantiationError: org/gjt/mm/mysql/Connection
at org.gjt.mm.mysql.Driver.connect(Driver.java:126)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at TestQuery.main(TestQuery.java:32)
I try to many times. Would you like to tell me how to solve the problem?
Thanks.
penny
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php