Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Why code can compiled successfully without mysql-connector-java-#-bin.jar installed

Why code can compiled successfully without mysql-connector-java-#-bin.jar installed

Scheduled Pinned Locked Moved Web Development
helpdatabasejavamysqlcom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cy163 hotmail com
    wrote on last edited by
    #1

    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.

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups