Jul 14, 2003 #1 4345487 Programmer Dec 31, 2002 132 US Hi, I'm trying to learn JSP and I would like if someone has an example of how to connect and get data from a SQl database. Thanks in advance
Hi, I'm trying to learn JSP and I would like if someone has an example of how to connect and get data from a SQl database. Thanks in advance
Jul 14, 2003 #2 palbano Programmer Oct 9, 1998 4,341 US Please refrain from cross posting -pete Upvote 0 Downvote
Jul 22, 2003 #3 MPJH Programmer Jul 22, 2003 6 NL Basically I use this: { Class.forName("com.mysql.jdbc.Driver" Connection myConn=DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=root" Statement stmt = myConn.createStatement(); String query = "SELECT count(messageNr) FROM messages"; ResultSet resultaat = stmt.executeQuery( query ); while(resultaat.next()) { String GetIT = resultaat.getString("count(messageNr)" out.println(" "+GetIT+"" } } Note that you need the MySQL connector JAR installed... greetz, Menno. Upvote 0 Downvote
Basically I use this: { Class.forName("com.mysql.jdbc.Driver" Connection myConn=DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=root" Statement stmt = myConn.createStatement(); String query = "SELECT count(messageNr) FROM messages"; ResultSet resultaat = stmt.executeQuery( query ); while(resultaat.next()) { String GetIT = resultaat.getString("count(messageNr)" out.println(" "+GetIT+"" } } Note that you need the MySQL connector JAR installed... greetz, Menno.