i am writing code and also the error i am facing in database connectivity in jsp to mysql .plz help me .thanx
code
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.*;
import java.io.*;
public class ConnBean
{
Connection conn;
Statement st ;
public ConnBean()
{
String sqlDriver= "com.mysql.jdbc.Driver";
String hostName = "localhost:3306/";
String dbName = "mydb";
String userID = "root";
String password = "webportal";
//databse URL
String dbURL = "jdbc:mysql://" + hostName + dbName;
try {
Class.forName(sqlDriver);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(dbURL, userID, password);
st = conn.createStatement();
System.out.println("db connected");
}
catch (SQLException e) {
System.out.println("Exception occured during get connection" + e);
}
}
public static void main(String asdas[]) throws SQLException
{
ConnBean conn=new ConnBean();
//ResultSet rs=conn.executeQ("select * from clients");
}
}
and the error that jdk 1.5 ( with mysql 5.0.41) is showing is
C:\Program Files\Java\jdk1.5.0\bin\java.exe ConnBean
Working Directory - D:\jsp code\
Class Path - .;c:\Kawapro5.0\kawaclasses.zip;c:\program files\java\jdk1.5.0\lib\tools.jar;c:\program files\java\jdk1.5.0\jre\lib\rt.jar
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at ConnBean.<init>(ConnBean.java:25)
at ConnBean.main(ConnBean.java:44)
Exception occured during get connectionjava.sql.SQLException: No suitable driver
Process Exit...