|
-
August 19th, 2008, 09:49 PM
#1
Why code can compiled successfully without mysql-connector-java-#-bin.jar installed
Hello All,
In my program, i want to use a Java servlet to response to users' web request, in which the info submitted by users is write into a remote MySQL database. To this end, I have to establish a connection to the MySQL database firsts. I do this using the following code and can compile it sucessfully. It is strange to me that the code can be compiled successfully,though there is actually not mysql-connector-java-###-bin.jar package installed/copied on the Linux box.
Code:
import java.sql.*;
import java.io.*;
import java.util.*;
public class welcomeyou extends HttpServlet
{
public void doGet(HttpServletRequest rqu, HttpServletResponse resp)
{
String driver="com.mysql.jdbc.Driver";
String url="jdbc:mysql://192.168.1.1/DatabaseName";
String databaseuser="root";
String password=""
Connection con = null;Statement smt =null;
Resultset rs=null;
try
{
con=DriverManager.getConnection(url, databaseuser, password);
smt =con.createStatement();
}
catch(SQLException E)
{
System.out.println("SQLException:" + E.getMessage());
System.exit(0);
}
}
}
I cannot provide error message, since the statement System.out.println("....) could not display error message on the screen in this circumstance.(Could anybody tell me how to do this )
I wonder if the statement 'import java.sql.*;' means import library from mysql-connector-java-###-bin.jar
Please help me, this problem has stuck me for a long time.
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|