Results 1 to 6 of 6

Thread: MySQL & JAVA

  1. #1
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    5

    Exclamation Unanswered: MySQL & JAVA

    Hi,

    I am having some problems displaying DB-info in IExplorer. When I run the applet in JBuilder I see all the info that is being queried from the DB. But when it's shown in a browser I get don't see anything. I've put a few 'System.out.println()' before and after the connection. As displayed below:
    Code:
    System.out.println("Before: connection");
    con = DriverManager.getConnection("jdbc:mysql://localhost/bubbels?user=root");
    System.out.println("After: connection"+ con);
    The JAVA-Console I only see the 'System.out.println("Before: connection");'. And the MySQL-Driver is being found.
    Last edited by elitearuba; 12-17-03 at 15:35.

  2. #2
    Join Date
    Nov 2003
    Posts
    11
    did u try doing with the ?user =root

  3. #3
    Join Date
    Nov 2003
    Posts
    11
    try doing without ?user=root

  4. #4
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    5
    Hmm...Now I don't see anything at all in JBuilder. The Applet runs on my own localhost using Apache. I don't see what could be causing the problem. And I don't get any Exception Messages either.

  5. #5
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    5

    Post

    Here are some more pieces of the code:

    Code:
        public Database() {
          try {
            Class.forName("org.gjt.mm.mysql.Driver");
            System.out.println("MySQL JDBC Driver found");
          }
          catch (java.lang.ClassNotFoundException e) {
            System.out.println("MySQL JDBC Driver not found...");
          }
        try {
          System.out.println("Before: connection");
          con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/bubbels?user=root");
          System.out.println("After: connection"+ con);
    Hope this stirs up a few more ideas....

  6. #6
    Join Date
    Nov 2003
    Posts
    11
    i did it on mine i got it. MySQL JDBC Driver found Before: connection After: connectioncom.mysql.jdbc.Connection@3afb99

    i think one reasons it wasn't working was it is suppose to be

    out.println("blah blahj")
    not
    System.out.prinln("blah blah")

    check out the following code and change it the way u want

    in out.println
    out is variable]

    here is the code and hope this helps



    import java.io.*;
    import java.util.*;
    import javax.swing.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;



    public class database extends HttpServlet
    {
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    try
    {

    Class.forName("com.mysql.jdbc.Driver");
    out.println("MySQL JDBC Driver found");
    out.println("Before: connection");

    Connection con;
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/project/");
    out.println("After: connection"+ con);
    }
    catch (Exception e) {
    out.println("MySQL JDBC Driver not found...");
    }
    }
    }


    later dude

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •