Hi,
please you help me, i want to connect a jsp with the mysql databse
how do i go about doing that.
please help.
nhlanhla
denis sorn
Ranch Hand
Joined: Apr 30, 2008
Posts: 33
posted
0
Java Server Pages have nothing to do with mysql. You can google for 'jdbc mysql' and you'll find a lot of quick starter tutorials about how to get and use mysql connection from java code.
You can then use the same method to obtain data in your servlet.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
MySQL handbook section. Look for the link about connector/J. Probably worth running some basic SQL from the command-line interface to confirm MySQL is running correctly first.
Java™ Tutorials section.
nhlanhla mazibuko
Greenhorn
Joined: Mar 28, 2008
Posts: 16
posted
0
This my jsp page, that i want connect it with the database.
this is a code.
help me.
Note that it's not a good practice to mix Java/JDBC code and JSP. The JDBC should be in a servlet (or class called from a servlet) and then forward to a JSP. It is harder to develop, troubleshoot, maintain and reuse code in a JSP. Which wil negatively impact getting it working.
In any case, what error do you get when you try to run your code?
Also, you should only have one try/catch. If an exception is caught, it doesn't make sense to continue.
@nhlanhla mazibuko
Is there any any specific reason for which you are not using JDBC Driver for MySQL. Here's a sample code below for connecting to MySQL using mysql Connector/J: