If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL & JAVA

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-17-03, 14:28
elitearuba elitearuba is offline
Registered User
 
Join Date: Dec 2003
Location: Netherlands
Posts: 5
Exclamation 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 14:35.
Reply With Quote
  #2 (permalink)  
Old 12-17-03, 15:21
simarjitraina simarjitraina is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
did u try doing with the ?user =root
Reply With Quote
  #3 (permalink)  
Old 12-17-03, 15:22
simarjitraina simarjitraina is offline
Registered User
 
Join Date: Nov 2003
Posts: 11
try doing without ?user=root
Reply With Quote
  #4 (permalink)  
Old 12-17-03, 15:30
elitearuba elitearuba is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 12-18-03, 11:26
elitearuba elitearuba is offline
Registered User
 
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....
Reply With Quote
  #6 (permalink)  
Old 12-19-03, 10:09
simarjitraina simarjitraina is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On