It looks like you don't have the driver in your classpath for it to be used by 
your simple application. 

If you haven't already downloaded it, head over to mysql site and grab yourself 
the driver and add it to your project path.

Again, always make sure you have a small runnable code sample to help reproduce 
the same issue. this should help us run the code and see where the problem lies.
The code you included does not show us any mistakes you may have in the rest of 
the code.

Good luck

--Evans
http://www.javawug.org

----- Original Message ----- 
  From: K M Nur 
  To: java-ee-j2ee-programming-with-passion@googlegroups.com 
  Sent: Sunday, December 28, 2008 10:27 PM
  Subject: [java ee programming] jdbc problem


  I'm trying to get connected to my mysql server running in linux using the 
following method -

  private static Connection getConnection() {
          Connection con = null;
          try {
                 System.out.println("test: not working after that.. why? find 
out!");
         Class.forName("com.mysql.jdbc.Driver");
         System.out.println("test");
          String url = "jdbc:mysql://localhost:3306/Movies";
          String user = "root";
          String pw = "";
          con  = DriverManager.getConnection(url, user, pw);
      }

  When I build and run in netbeans 6.1 I get the following output -

  test: not working after that.. .why? find out!
  com.mysql.jdbc.Driver


  When I try the following -

  Connection con = null;
      try {

  // Load the MySQL JDBC driver
        Class.forName("com.mysql.jdbc.Driver") ;
        System.out.println("MySQL JDBC driver loaded ok.");
   
      } catch (Exception e) {
        System.err.println("Exception: "+e.getMessage());
      }

  I get the following output -
  Exception: com.mysql.jdbc.Driver

  I can see my mysql databases in the services window (when I select and right 
click on the database I'm trying to connect from the code it can connect with 
database) and it shows my database. However the above codes not working...

  What am I doing wrong?
  Please help.

  -- 
  Regards,
  K M Nur

  Mobile : +88-01914 064920
  Tech Blogs & Schedules: http://k-linuxtechs.blogspot.com


  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to