User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 427,859 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,648 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 4908 | Replies: 13
Reply
Join Date: Feb 2006
Posts: 1,461
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 131
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Please help me in connecting JSP to MySql

  #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  
Join Date: Mar 2007
Posts: 7
Reputation: A Yasir is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
A Yasir A Yasir is offline Offline
Newbie Poster

Question Re: Please help me in connecting JSP to MySql

  #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  
Join Date: Feb 2006
Posts: 1,461
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 131
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Please help me in connecting JSP to MySql

  #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  
Join Date: Mar 2007
Posts: 7
Reputation: A Yasir is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
A Yasir A Yasir is offline Offline
Newbie Poster

Re: Please help me in connecting JSP to MySql

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 3:39 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC