Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Firstly, Im struggling with connecting jsp to mysql on Debian Woody - i have installed j2sdk1.3, tomcat4 and mysql and i have also installed libmysql-java - Java database (JDBC) driver for MySQL to connect mysql to tomcat - I can not get a script to connect to the mysql - its say "can not connect to database"- Can anyone point me in the right direction?
Second problem, I'm looking for a script where you can add text, etc and it saves it to a html page in a directory?
Is mysql running on the same box as the jsp? Can you login to mysql using the mysql client? "Can not connect to database" sounds like either a network problem or the mysql database isn't up. Once you get past that you'll be into the world of permissions problems. Would it be possible to post the JSP/Servlet you're using to connect to MySQL?
In mysql, i created a user testuser and testpass and granted all privilages for that user on database test.
You wouldnt happen to have any better code to try would you?
Also do I need to put any jar files anywhere and if so, where - I have no idea which ones and how to put them in the CLASSPATH
Yes, you definitely need the jar containing the mysql JDBC connector in you WEB_INF/lib directory (that's the easiest place to put it...). Jar files in the WEB-INF/lib directory should automatically be added to the classpath by the servlet/JSP container (tomcat). Here's some code I have used to create MySQL connections in java:
Well I can log in to mysql:
mysql -h localhost -u testuser -ptestpass, and there is a default 'test' database, thats about all ive done for mysql - Anything else? Do I need to grant prviliages for that user to that database?
plus where should the mysql-connector-java-3.0.15-ga.jar file go ?- there are multiple WEB-INF directories, for example:
/var/lib/tomcat4/webapps/ROOT/WEB-INF
/var/lib/tomcat4/webapps/examples/WEB-INF/
/var/lib/tomcat4/webapps/webdav/WEB-INF
i think it might ignore CLASSPATH, so I really wanted to actually put the jar file in the required directory - I have not added anything to the class path.
Once again, thanks for your help, much appreciated..
first, about that incompatible types error, I think you should try changing the name of the class your using from Connection as that looks like it's creating a name conflict with java.sql.Connection.
second, the jar file needs to go in the WEB-INF directory of the webapp that you're working on. The simplest case is that you're creating a folder in the tomcat/webapps directory. This then becomes your webapp and has a minimum structure like this:
mywebapp
|--myfile.jsp
|--WEB-INF
|--web.xml
|--lib
|--all the jar files for the application
|--classes
|---all the java packages you're developing
You would then access this application at http://localhost:8080/mywebapp/myfile.jsp for a default tomcat install. This may not be an adequate explanation; if you need more google for information about webapps. You really ought to have a good understanding of the standard structure of a webapp
whoops, looks like they stripped out my leading spaces...
mywebapp
|--myfile.jsp
|--WEB-INF
__|--web.xml
__|--lib
____|--all the jar files for the application
__|--classes
____|---all the java packages you're developing
i have a directory called 'classes', 'jsp' and a file called web.xml - So should I create a webapp in the WEB-INF directory and then insert the ' mysql-connector-java-3.0.15-ga-bin.jar' in that newly created webapp directory?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.