#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    41
    Rep Power
    12

    Connect JSP to MySQL


    Hi All

    I have an requirement which has to be Developed in JSP and MySQL
    Can anybody give me an example how to connect from JSP to MySQL on Linux machine (Using tomcat)

    Any help in this regard is highly appreciated.

    Thanks & Regards
    Katta Srinivas
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    String url = "jdbc:mysql://<host>/<database>?user=&password=";
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    java.sql.Connection connection = java.sql.DriverManager.getConnection(url);
    java.sql.Statement statement = connection.createStatement();
    java.sql.ResultSet columns = statement.executeQuery(query);
    while(columns.next())
    {
    out.println(columns.getString(1));
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    41
    Rep Power
    12
    Thank you for the reply, That solved My problem

IMN logo majestic logo threadwatch logo seochat tools logo