Author
problem about mysql driver
Abhijit Kangale
Greenhorn
Joined: Sep 17, 2009
Messages: 26
posted Feb 09, 2010 03:16:27
Hi all,
I am developing some application on Linux machine where I need to establish database connection using mysql driver. I have written following code for that.
------------PROGRAM--------------------------------------------------------------------------------------------------
<%@ page import="java.sql.*" %>
<%@ page language="java" %>
<html>
<head>
<title> Doctor's Work Bench </title>
</head>
<body>
<center><h1> Welcome to Immunization Page </h1><br><br>
<%
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
;
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select IMMUNISATION_NAME from IMMUNISATION_REF_T");
while(rs.next())
{
String str=rs.getString("IMMUNISATION_NAME");
%>
<textarea rows="25" cols="20"> <%=str%> </textarea></center>
<% }
}
catch(Exception e)
{
out.println("Some Error has occoured"+e);
e.printStackTrace();
}
%>
</body>
</html>
-------------------------------------- END PROGRAM--------------------------------------------------------------------------------------------------
but when I execute the same in the browser it is giving following exception in the browser==>
ClassNotFoundException : com.mysql.jdbc.Driver
Can anyone help me to solve this problem.
Thanks & Regards,
Abhijit
Deepak Bala
Bartender
Joined: Feb 24, 2006
Messages: 4860
posted Feb 09, 2010 03:35:05
Put the jar on the classpath
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Abhijit Kangale
Greenhorn
Joined: Sep 17, 2009
Messages: 26
posted Feb 09, 2010 03:55:25
Hi Deepak,
Will you please tell me what commands I needs to follow on Linux machine to put jar file on class path. Actually I am new to Linux.
Thanks & Regards,
Abhijit
Deepak Bala
Bartender
Joined: Feb 24, 2006
Messages: 4860
posted Feb 09, 2010 04:09:29
Use the export command
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Abhijit Kangale
Greenhorn
Joined: Sep 17, 2009
Messages: 26
posted Feb 09, 2010 04:31:04
Hi Deepak,
Thanks for your reply. Please give the detailed format of that command. I m completly new to Linux. n I really have less time to solve this problem.
Regards,
Abhijit
Deepak Bala
Bartender
Joined: Feb 24, 2006
Messages: 4860
posted Feb 09, 2010 04:55:44
If you are running out of time, I suggest you google a little faster
http://www.ibm.com/developerworks/library/l-bash.html
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format