my dog learned polymorphism*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySql with JSP" Watch "MySql with JSP" New topic
Author

MySql with JSP

Eduardo Tusco
Greenhorn

Joined: May 09, 2003
Posts: 5
Hello,
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
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

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.
Class.forName("com.mysql.jdbc.Driver").newInstance();
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: http://aspose.com/file-tools
 
subject: MySql with JSP