Problems with accessing to mySQL database from a web-application
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, August 12, 2003 03:41 AM

Problems with accessing to mySQL database from a web-application I want to get a JDBC connection to a mySQL database on a web-hotel. I have downloaded this driver: mysql-connector-java-3.0.8-stable-bin.jar and have put in the map WEB-INF/lib. My code looks like this: Class.forName("com.mysql.jdbc.Driver").newInstance(); db = DriverManager.getConnection("jdbc:mysql://host/dbname?user=username&password=password"); Have I done anything wrong? I don´t have access to any log files, that´s why I can´t see the errors it makes! Thanks Jeppe    More>>

Problems with accessing to mySQL database from a web-application


I want to get a JDBC connection to a mySQL database on a web-hotel. I have downloaded this driver:


mysql-connector-java-3.0.8-stable-bin.jar


and have put in the map WEB-INF/lib.


My code looks like this:


			
Class.forName("com.mysql.jdbc.Driver").newInstance();
db = DriverManager.getConnection("jdbc:mysql://host/dbname?user=username&password=password");



Have I done anything wrong? I don´t have access to any log files, that´s why I can´t see the errors it makes!


Thanks Jeppe    <<Less

Re: Problems with accessing to mySQL database from a web-application

Posted By:   Joost_Schouten  
Posted On:   Tuesday, August 12, 2003 04:07 AM

Taken that db is of the java.sql.Connection type, I can't see a direct problem.



But you should somehow make sure you get access to your error logs or build your own propper error handling. By defining your own error page in your web.xml and have that page display the error thrown is not only usefull, it's an absolute must. There are lodes of things that can go wrong here.


Below I printed a very simple error page, and below that the tags to add to your web.xml. thios will show you the exception thrown.


save this file as error.jsp and place in your root-------


<%@ page isErrorPage="true" %>





Error page






Exception thrown:





<%if(exception != null){

out.print("

");

exception.printStackTrace(new PrintWriter(out));

out.print("
");

}

%>





place this at the end of your web.xml------------



java.lang.Throwable

error.jsp


Good luck,

Joost
About | Sitemap | Contact