Jay Kandy
Posts: 77
Nickname: jay
Registered: Mar, 2002
|
|
Re: Connect mySQL by using JDBC in linux
|
Posted: Dec 22, 2002 6:20 PM
|
|
Heres my 2 cents worth:
1. You need to include your jar file when compiling your classes this way: javac -classpath c:\path\to\mysql-connection-java-2.0.14-bin-jar YourClass.java I suggest you test write there in your work folder. Put your code in a try block and check for messages. After you think its OK, move your servlet to Tomcat.
try
{
//...sql code
}
catch(ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch(SQLException sqle)
{
System.err.println("Error Code:" + sqle.getErrorCode());
System.err.println("SQL State:" + sqle.getSQLState());
sqle.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
2. Put your class file in classes folder. But plcae your jar file in $TOMCAT_HOME/lib i.e, the lib directory used by all applications.
Hope that helps.
-Jay
|
|