This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes MySql with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySql with JSP" Watch "MySql with JSP" New topic

MySql with JSP

Eduardo Tusco

Joined: May 09, 2003
Posts: 5
How can I connect MySql DB with JSP? Do I need a specific JDBC or ODBC?
And I don�t know how to set MySql up in my WinXP!!!
Could you help? Thanks in advance!
Joe Ess

Joined: Oct 29, 2001
Posts: 8915

MySQL has some excellent documentation, including a chapter on Installing on Windows. As for connecting to a database, have you used JDBC before? If not, check out the tutorials in the JDBC Documentation. JSP pages get compiled into servlets so you can use JDBC in them like you would in any other Java program.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Annemarie McKeown
Ranch Hand

Joined: Nov 07, 2003
Posts: 47
Very simple something like the following will connect to your database and allow you to submit a query...
assuming homework is the name of the database and the user name is root.
Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost/homework?user=root");
Statement stmt = myConn.createStatement();
stmt.executeUpdate("some query....");
You'll also need a mysql-connector.jar downloaded and installed in your webapp.
Hope this helps.
[ March 01, 2004: Message edited by: Annemarie McKeown ]
I agree. Here's the link:
subject: MySql with JSP