由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - HELP!!!Connect to MySQL in JSP
相关主题
configuration about mysql!!![转载] 还有个技术问题,请大拿们指导
[转载] how to set up the classpath?JSP access database的问题
帮帮忙: JDBC怎么不能用?请问如何算出这个天数来
这里有人对sqlj熟悉吗, 有个很急的问题?MySQL: cannot connect
急问:Oracle JDBC 问题mysql 一问
[转载] Java/JSP/Servlets... and Database(Oracle/DB2)求救:为什么Run mysql Under Win98时出错??
jdbc to db2 on linux问题Problem Running MySql on W2K
Desperate help neede: DB2 connection in JSP Through JDBC drivermysql question
相关话题的讨论汇总
话题: jsp话题: classpath话题: mysql话题: tomcat话题: lib
进入Database版参与讨论
1 (共1页)
m*****g
发帖数: 8
1
I got java.lang.ClassNotFoundException when i link to MySQL in JSP file, and i
also sure that is database can't connected. The class called in JSP is working
well when it called by a Java file under the same system, and that class is
dedicating to link database. So i think problem is on Tomcat3's configuration,
any guru can help?
m*****e
发帖数: 126
2
Not necessarily Tomcat's problem. You should test your JDBC driver program. It
should be in your CLASSPATH. One thing you can do is to write a standalone
program to do a database query. If this works, then copy the db access code to
your JSP.

i
working
configuration,

【在 m*****g 的大作中提到】
: I got java.lang.ClassNotFoundException when i link to MySQL in JSP file, and i
: also sure that is database can't connected. The class called in JSP is working
: well when it called by a Java file under the same system, and that class is
: dedicating to link database. So i think problem is on Tomcat3's configuration,
: any guru can help?

m*****g
发帖数: 8
3
Hi thanks man
That what i did, the JDBC driver standalone testing code is working well when
it called by a JAVA main file, but not when called by JSP file. The code i use
is following:
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://localhost/mike ?user=mike&password=mike");
System.out.println("connected to database");
} catch(ClassNotFoundException cnfe){
error="ClassNotFoundException: Could not loc

【在 m*****e 的大作中提到】
: Not necessarily Tomcat's problem. You should test your JDBC driver program. It
: should be in your CLASSPATH. One thing you can do is to write a standalone
: program to do a database query. If this works, then copy the db access code to
: your JSP.
:
: i
: working
: configuration,

m*****e
发帖数: 126
4
Copy the mm driver's jar file into TOMCAT_HOME/lib directory and restart the
server and try again. That is the default place where TOMCAT looks for
external libraries.

when
use
mm.mysql.jar,
do
program.
code

【在 m*****g 的大作中提到】
: Hi thanks man
: That what i did, the JDBC driver standalone testing code is working well when
: it called by a JAVA main file, but not when called by JSP file. The code i use
: is following:
: try{
: Class.forName("org.gjt.mm.mysql.Driver").newInstance();
: con = DriverManager.getConnection(
: "jdbc:mysql://localhost/mike ?user=mike&password=mike");
: System.out.println("connected to database");
: } catch(ClassNotFoundException cnfe){

m*****g
发帖数: 8
5
Ya that was i tried, but still not working. When i use printSteakTrace instead
of errorException, it shows 'No suitable Driver'. Definitely, it results from
wrong URL which specified in DriverManager. And also the driver actually has
already found out. So i use IP and domain mane instead of 'Localhost', it
returns a null pointer, that means no database connected and i can't do
anything on Database.
Any idea?Thx
【 在 macelee (星星) 的大作中提到: 】
m*****e
发帖数: 126
6
I read your code in detail and found a program!!!!!!!!!
You have an extra space in your connection string before the question mark.
Does that also appear in your source code?

when
use
mm.mysql.jar,
do
program.
code

【在 m*****g 的大作中提到】
: Hi thanks man
: That what i did, the JDBC driver standalone testing code is working well when
: it called by a JAVA main file, but not when called by JSP file. The code i use
: is following:
: try{
: Class.forName("org.gjt.mm.mysql.Driver").newInstance();
: con = DriverManager.getConnection(
: "jdbc:mysql://localhost/mike ?user=mike&password=mike");
: System.out.println("connected to database");
: } catch(ClassNotFoundException cnfe){

B**z
发帖数: 153
7
it's a typical ClassNotFoundException for JDBC, it occurs at Class.forName()
check the classpath setting in your JSP environment.

【在 m*****e 的大作中提到】
: I read your code in detail and found a program!!!!!!!!!
: You have an extra space in your connection string before the question mark.
: Does that also appear in your source code?
:
: when
: use
: mm.mysql.jar,
: do
: program.
: code

B**z
发帖数: 153
8
print out the classpaht before Class.forName()
using System.getProperty("java.class.path")
to see if the database drive class in in the classpath

【在 m*****g 的大作中提到】
: Ya that was i tried, but still not working. When i use printSteakTrace instead
: of errorException, it shows 'No suitable Driver'. Definitely, it results from
: wrong URL which specified in DriverManager. And also the driver actually has
: already found out. So i use IP and domain mane instead of 'Localhost', it
: returns a null pointer, that means no database connected and i can't do
: anything on Database.
: Any idea?Thx
: 【 在 macelee (星星) 的大作中提到: 】

m*****g
发帖数: 8
9
I definitely set the driver up in classpath, and the code i post is a sub
class that in charge of linking to database. Again, when i use a .java file to
call this class then it link to mysql well, but not when i use .jsp to call
it. So i think if its classpath wrror, it shouldn't work on .java file right?
Moreover, when i copy the driver to my_jsp_home_directory/WEB-INF/lib/ , the
.jsp file will work.
Any idea?Thx
m*****g
发帖数: 8
10
Thx man, in .jsp, the system return me the java-class-path is
{Tomcat_Home}/lib/tomcat.jar, instead of mm.mysql.jar in the same directoy.
Also, in profile , i set classpath to {Tomcat_Home}/lib/ and to
{Tomcat_Home}/lib/mm.mysql.jar, but not {Tomcat_Home}/lib/tomcat.jar.
And when i try this statement in .java file, it returns all paths which i set
in profile's classpath.
Again, when i move the driver to {my-jsp-home}/WEB-INF/lib/, which makes .jsp
link mysql working well as .java does, the syste

【在 B**z 的大作中提到】
: print out the classpaht before Class.forName()
: using System.getProperty("java.class.path")
: to see if the database drive class in in the classpath

相关主题
[转载] Java/JSP/Servlets... and Database(Oracle/DB2)[转载] 还有个技术问题,请大拿们指导
jdbc to db2 on linux问题JSP access database的问题
Desperate help neede: DB2 connection in JSP Through JDBC driver请问如何算出这个天数来
进入Database版参与讨论
B**z
发帖数: 153
11
the CLASSPATH for your user profile is for the user environment, for JSP,
it's different,you have to put the classpat in WEB-INF/lib as you described.

【在 m*****g 的大作中提到】
: Thx man, in .jsp, the system return me the java-class-path is
: {Tomcat_Home}/lib/tomcat.jar, instead of mm.mysql.jar in the same directoy.
: Also, in profile , i set classpath to {Tomcat_Home}/lib/ and to
: {Tomcat_Home}/lib/mm.mysql.jar, but not {Tomcat_Home}/lib/tomcat.jar.
: And when i try this statement in .java file, it returns all paths which i set
: in profile's classpath.
: Again, when i move the driver to {my-jsp-home}/WEB-INF/lib/, which makes .jsp
: link mysql working well as .java does, the syste

m*****g
发帖数: 8
12
You mean put driver or classpath to /WEB-INF/lib?
i knew put driver there it is working, but if there are hundred users, i got
to put that driver(or mirror) to all of their folders. Is there anyway i can
set a classpath and all users don't need put the driver(or mirror) under their
/WEB-INF/lib directory?

【在 B**z 的大作中提到】
: the CLASSPATH for your user profile is for the user environment, for JSP,
: it's different,you have to put the classpat in WEB-INF/lib as you described.

B**z
发帖数: 153
13
here is the HOW-TO from Apache.org
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
The following rules cover about 95% of the decisions that application
developers and deployers must make about where to place class and resource
files to make them available to web applications:
For classes and resources specific to a particular web application, place
unpacked classes and resources under /WEB-INF/classe of your web application
archive, or place JAR files containing those cl

【在 m*****g 的大作中提到】
: You mean put driver or classpath to /WEB-INF/lib?
: i knew put driver there it is working, but if there are hundred users, i got
: to put that driver(or mirror) to all of their folders. Is there anyway i can
: set a classpath and all users don't need put the driver(or mirror) under their
: /WEB-INF/lib directory?

m*****g
发帖数: 8
14
Thx Buzz
I notice that is tomcat4.1 doc, but i am using 3.3. So when i tried it , seems
doesn't work anymore.

got
can
JSP,

【在 B**z 的大作中提到】
: here is the HOW-TO from Apache.org
: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
: The following rules cover about 95% of the decisions that application
: developers and deployers must make about where to place class and resource
: files to make them available to web applications:
: For classes and resources specific to a particular web application, place
: unpacked classes and resources under /WEB-INF/classe of your web application
: archive, or place JAR files containing those cl

h********d
发帖数: 2
15
In Tomcat 3.3, the class loader scheme ignores your CLASSPATH
setting. Instead, you may add needed jars to Tomcat's "lib/apps",
"lib/common", and "lib/container" directories. See the "readme" file
in Tomcat's "doc" directory for details.


seems
application
or

【在 m*****g 的大作中提到】
: Thx Buzz
: I notice that is tomcat4.1 doc, but i am using 3.3. So when i tried it , seems
: doesn't work anymore.
:
: got
: can
: JSP,

m*****g
发帖数: 8
16
Thank you helloworld so much, i finally get that doc and beat that problem
down, and also find out the structure change from 3.3 to 4.0. Thx BUZZ too.

resource
place
applications,
$CATALINA_HOME/shared/classes,
i
i
under

【在 h********d 的大作中提到】
: In Tomcat 3.3, the class loader scheme ignores your CLASSPATH
: setting. Instead, you may add needed jars to Tomcat's "lib/apps",
: "lib/common", and "lib/container" directories. See the "readme" file
: in Tomcat's "doc" directory for details.
:
:
: seems
: application
: or

1 (共1页)
进入Database版参与讨论
相关主题
mysql question急问:Oracle JDBC 问题
mysql C API[转载] Java/JSP/Servlets... and Database(Oracle/DB2)
anonymous login in mysql?jdbc to db2 on linux问题
问个问题: Can't connect to MySQL server on 'dbhost' (10061) ( 2003 )Desperate help neede: DB2 connection in JSP Through JDBC driver
configuration about mysql!!![转载] 还有个技术问题,请大拿们指导
[转载] how to set up the classpath?JSP access database的问题
帮帮忙: JDBC怎么不能用?请问如何算出这个天数来
这里有人对sqlj熟悉吗, 有个很急的问题?MySQL: cannot connect
相关话题的讨论汇总
话题: jsp话题: classpath话题: mysql话题: tomcat话题: lib