Please help me in connecting JSP to MySql

Reply

Join Date: Feb 2006
Posts: 2,358
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Please help me in connecting JSP to MySql

 
0
  #11
Apr 3rd, 2007
Try downloading a newer version of the Driver.
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: A Yasir is an unknown quantity at this point 
Solved Threads: 1
A Yasir A Yasir is offline Offline
Newbie Poster

Re: Please help me in connecting JSP to MySql

 
0
  #12
Apr 4th, 2007
I have tried using it with the newer version but its giving error again at the connection string and having root cause:
javax.servlet.ServletException: Communications link failure due to underlying exception:

A few ambiguities more to ask

1-- Can any one tell me that if i am using apache-tomcat-5.5.23, so do i still need to install apache server separately and make connection with tomcat later on

2-- If WEB-INF subdirectory of tomcat is to be targeted to create a WEB-INF\web.xml file and if i search this subdirectory i can find it in many flders like
webapps\ROOT, tomcat-docs, jsp-examples, servlets-examples, balance, webdav, tomcat-docs\appdev\sample\web,
server\webapps\manager, host-manager ,
so which one exactly has to be target. what i think is ROOT but need a confirmation.

3-- Do i need to add anything like modifying server.xml in tomcat directory , and i got 2 different resourse declaration in MySQL documentation and one in tomcat documentation, so which one to use and i cant get this
<Resource name="jdbc/MySQLDB"
auth="Container"
type="javax.sql.DataSource"/>
what would be MySQLDB in my case???
4-- I have my Jre folder both in C:\Program Files and within jdk folder as i installed java at some other folder rather than c:\ , so which one would my tomcat should use?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,358
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Please help me in connecting JSP to MySql

 
0
  #13
Apr 4th, 2007
Now that you have a decent driver, I would say to change ("jdbc:mysql://localhost:8009/login? user='root'&password='mdas'"); to ("jdbc:mysql://localhost:8009/login", "root", "mdas");

Also, that space between the ? and the word user in the original url will cause problems anyway, even if the DriverManager does accept the url with user and password as parameters on the url, as there should not be a space there.

The web.xml is placed directly under WEB-INF, not any of its subdirectories.

And, no you do not need to install apache, but it is advised to use a real browser as the front end (in this case apache) and connect to the tomcat locally through the webserver (in this case using mod_jk).
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: A Yasir is an unknown quantity at this point 
Solved Threads: 1
A Yasir A Yasir is offline Offline
Newbie Poster

Re: Please help me in connecting JSP to MySql

 
0
  #14
Apr 4th, 2007
Originally Posted by masijade View Post
Now that you have a decent driver, I would say to change ("jdbc:mysql://localhost:8009/login? user='root'&password='mdas'"); to ("jdbc:mysql://localhost:8009/login", "root", "mdas");

Also, that space between the ? and the word user in the original url will cause problems anyway, even if the DriverManager does accept the url with user and password as parameters on the url, as there should not be a space there.

The web.xml is placed directly under WEB-INF, not any of its subdirectories.

And, no you do not need to install apache, but it is advised to use a real browser as the front end (in this case apache) and connect to the tomcat locally through the webserver (in this case using mod_jk).

Tried that as well , i think the problem might not be with the code , it might be with the configuration, as i was looking at tomcat-apache documentation it says to create a WEB-INF/web.xml file even given teh code is given

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

just need to ask a few questions before starting any new thing

1. the tomcat directory already has many WEB-INF/web.xml files at different locations , as i have mentioned before so do i need to modify any of it or do i have to create a new folder name WEB-INF and create the web.xml in it. and if this is teh case where should i create that WEB-INF folder with in $CATALINA_HOME/.

2. teh second question is what is jdbc/TestDB as it is also used in $CATALINA_HOME/conf/server.xml resourse tag as well and what would be it in my case??

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="mdas" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:8009/login?autoReconnect=true"/>

3. I have my Jre folder both in C:\Program Files and within jdk folder as i installed java at some other folder rather than c:\ , so which one would my tomcat should use while directing for installaion?

if u can answer my ambiguities i'll be really thankful
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC