GeeCON Prague 2014*
The moose likes JDBC and the fly likes problem about mysql driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem about mysql driver" Watch "problem about mysql driver" New topic
Author

problem about mysql driver

Abhijit Kangale
Ranch Hand

Joined: Sep 17, 2009
Posts: 39
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
Posts: 6661
    
    5

Put the jar on the classpath


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Abhijit Kangale
Ranch Hand

Joined: Sep 17, 2009
Posts: 39
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
Posts: 6661
    
    5

Use the export command
Abhijit Kangale
Ranch Hand

Joined: Sep 17, 2009
Posts: 39
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
Posts: 6661
    
    5

If you are running out of time, I suggest you google a little faster

http://www.ibm.com/developerworks/library/l-bash.html
 
GeeCON Prague 2014
 
subject: problem about mysql driver