Please support our JSP advertiser: Lunarpages JSP Web Hosting
![]() |
•
•
•
•
yes i have copied the .jar files in WEB-INF/lib but still when i have compiled database connectivity program with mysql in java it gave the same error.
D:\Program Files\Java\jdk1.5.0\bin\java.exe ConnBean
Working Directory - C:\final project\jsp code\
Class Path - .;c:\Kawapro5.0\kawaclasses.zip;d:\program files\java\jdk1.5.0\lib\tools.jar;d:\program files\java\jdk1.5.0\jre\lib\rt.jar
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
....
Why are you trying to run the ConnBean from the jdk bin folder if you wish to access this through Tomcat? If you want to run from the command line, you need to specify the classpath. Many posts have told you how to do that. If you have a JSP/servlet app running in Tomcat that needs that ConnBean, then placing the jar in WEB-INF/lib for that app is all that you need to do.
•
•
•
•
2masijade I beginner in java too. So sometimes copy jars to jre folder (when project not compiled and i am angry)
And as a quick fix to get something compiled or run for the first time when you are frustated, and it is not meant as a solution, but rather just a quick stopgap, I don't object to it that much (although it still should not be done, it shouldn't get to that point, but sh1t happens sometimes). The real problem comes in (at least the point where I get upset about it) is when I see someone suggest that as the solution for a problem.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,875
Reputation:
Rep Power: 14
Solved Threads: 344
It always start with quick fix, but in no time you find that quick fix project is project on which you work for weeks/months. You submit to your teacher/employer/customer to find "suddenly" it does not work for them.
So as masijade and others said it is always best to do it proper way.
So as masijade and others said it is always best to do it proper way.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I think for a beginner important to make the project efficient. And then to understand details. If the program does not work - that to test there is nothing. Though I too for the serious approach in development of commercial projects. But adjustment connector for a DB is not so critical in comparison with realization of architecture of the project. For example now I develop the project in team of developers. It stored on VSS and not depend on local settings developers computer. But its not thought over project architecture would be a big problem.
•
•
Join Date: Jul 2007
Posts: 11
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Bad, bad, bad. Never copy anything to the lib/ext directory of the jre. Learn how to use and set classpaths properly. If he has the proper jarfile, and places it in the WEB-INF/lib directory of the web application he is trying to reach, the classes will be found. If they are not, he has done something wrong. Either copied it to the lib directory of the wrong application, not copied the right jarfile, or, maybe, somehow or another, changed the tomcat configuration so that it does not look there. Sorry to say it, but all of those things are "his problem", and copying anything to the lib/ext directory is not the answer, regardless of whether or not "it works".
1) i have copied mysql-connector-java-3.0.8-stable-bin this zipped file and also imn unzipped form in WEBINF/lib .which jar files u are talking about please mention complete name .and
2) tell me by doing this can i remove the error encountering in kawapro also as i have mentioned above .
If your application runs in tomcat, place any and all jarfiles that it needs into the WEB-INF/lib directory of the application. You should know what the jars are, since you are the one writing the application. If you can no longer remember the name of a specific jar, then download it again. If, after placing the jar(s) in WEB-INF/lib, you still get a ClassNotFoundException, then you have either copied it to the WEB-INF/lib directory of the wrong application, or you have done something to the Tomcat configuration which prevents it from loading libraries in that directory. What that might be, I cannot even begin to tell you. All of this, of course, assumes that you are accessing the application through Tomcat, and a browser, of course. If you are attempting to execute something from the command line, then you should use the -cp option to specify the classpath (specifying the full complete path to each individual jarfile needed) when you type java (if the class will even function from the command line, which Servlets and JSPs definately will not (and most, if not all Beans, also should not, except indirectly, i.e. accessed from a different class which is executed).
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jul 2007
Posts: 11
Reputation:
Rep Power: 0
Solved Threads: 0
oh my dear ! i am working with tomacat apache 5.0.28 but in order to work with beans there is also need to make a java file and place it in classes in tomcat directory .thats why i am running the program on jdk 1.5 +kawapro5 in order to connect the mysql database with jsp.
and the the jsp code is given below that i am using with this java file or class file
<%@page import="java.sql.*,java.util.*" %>
<jsp:useBean id="connBean" scope="page" class="ConnBean" />
<html>
<head>
<script>
function validate(f){
if(f.id.value.length == 0){
alert('User Id can no be empty.');
f.id.focus();
return false;
}
else if(f.pswd.value.length == 0){
alert('Password can no be empty.');
f.pswd.focus();
return false;
}
}
</script>
<title>Log In</title>
</head>
<body onLoad="document.login.id.focus()">
<center>
<%
String query="insert into dbname(id,password) values('2222','222')";
String url=request.getRemoteAddr();
try
{
int t=connBean.executeUp(query);
if(t>0)
out.print("query successfull");
else
out.print("query not successfull");
}
catch(Exception e)
{}
</body>
</html>
but how tomcat will run it properly untill its class file(.java file) works properly.
and the the jsp code is given below that i am using with this java file or class file
<%@page import="java.sql.*,java.util.*" %>
<jsp:useBean id="connBean" scope="page" class="ConnBean" />
<html>
<head>
<script>
function validate(f){
if(f.id.value.length == 0){
alert('User Id can no be empty.');
f.id.focus();
return false;
}
else if(f.pswd.value.length == 0){
alert('Password can no be empty.');
f.pswd.focus();
return false;
}
}
</script>
<title>Log In</title>
</head>
<body onLoad="document.login.id.focus()">
<center>
<%
String query="insert into dbname(id,password) values('2222','222')";
String url=request.getRemoteAddr();
try
{
int t=connBean.executeUp(query);
if(t>0)
out.print("query successfull");
else
out.print("query not successfull");
}
catch(Exception e)
{}
</body>
</html>
but how tomcat will run it properly untill its class file(.java file) works properly.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,749
Reputation:
Rep Power: 19
Solved Threads: 200
•
•
•
•
thats why i am running the program on jdk 1.5 +kawapro5 in order to connect the mysql database with jsp
God forbid you'r learn how to do things properly, right?
And your JSP is a disaster area. NEVER put Java code in a JSP. And ALWAYS close ALL database resources as soon as you're done with them.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
•
•
oh my dear ! i am working with tomacat apache 5.0.28 but in order to work with beans there is also need to make a java file and place it in classes in tomcat directory .thats why i am running the program on jdk 1.5 +kawapro5 in order to connect the mysql database with jsp.
Servlets are also java files (and JSPs are too, indirectly, since they will be translated to one the first time accessed after being changed). There is no reason you cannot test the Bean inside of the application. I assume you know how it will be used, so simply perform those actions through the browser (and at first you can have the bean log all sorts of things as kind of a "ppor man's" debug). Either that or write a separate Class that does nothing but call all the methods of the Bean, and which contains a main method, and call that. Then, like I said, include all jars on the command line with the -cp option. It's not that hard.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
Other Threads in the JSP Forum
Other Threads in the JSP Forum
- Previous Thread: getting values from drop down menu
- Next Thread: Encoding Format WEb.XMl
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






)
Linear Mode