Revision: 24097
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 21, 2010 02:48 by sukantahazra
Initial Code
import java.util.logging.Level;
import java.util.logging.Logger;
// import com.mysql.jdbc.*;
import java.sql.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sukanta
*/
public class Main {
public static void main(String[] args) throws SQLException {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
con = DriverManager.getConnection("jdbc:mysql://desktop:3306/employees", "sukanta", "sukanta");
stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM table1");
while (result.next())
System.out.println(result.getString(1) + " " + result.getString(2));
result.close();
con.close();
}
}
Initial URL
Initial Description
Initial Title
JDBC MySQL quick start
Initial Tags
mysql, java
Initial Language
Java