IntelliJ open source
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of Flex 4 in Action this week in the Flex forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » JDBC
 
RSS feed
 
New topic
Author

problem about mysql driver

Abhijit Kangale
Greenhorn

Joined: Sep 17, 2009
Messages: 26

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

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

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

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

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

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
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » JDBC
 
RSS feed
 
New topic
The most intelligent Java IDE

.