Hi raj,

Please check whether the library is placed or not for mysql 
connectivity...search on google for jar...

-----Original Message-----
From: Rajveer Singh <torajveersi...@gmail.com>
Sent: 23 April 2011 12:43
To: javaprogrammingwithpassion@googlegroups.com
Subject: [java programming] Trying to run my very first JDBC program

Hello guys,
 
I've written my very first program in JAVA for jdbc connection with mysql as 
below:-
 
[root@base laxman]# cat database.java
import java.sql.*;
   class database
     {
      public static void main(String args[]) throws Exception
       {
        //register driver
        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        //Establish connection
        Connection 
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=redhat");
        //Create a sql statement
        Statement stmt=con.createStatement();
        //Excecute the statement
        ResultSet rs= stmt.executeQuery("show databases");
        //retrieve from resultset and desplay data
        while(rs.next())
          {
                System.out.println(rs.getString(1));
          }
        //close connection
        con.close();
    }
}

[root@base laxman]#
but when I try to compile it, it's giving me following error:-
[root@base laxman]# javac database.java
database.java:8: package com.mysql.jdbc does not exist
        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
                                                       ^


[The entire original message is not included]

-- 
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to