Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySql with JSP

 
Eduardo Tusco
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Annemarie McKeown
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic