import java.sql.*;
/**
*
* @author Administrator
*/
public class jdbc_test {
/** Creates a new instance of jdbc_test */
public jdbc_test() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Connection con1=null;
Statement stmt1=null;
ResultSet rs1=null;
//PreparedStatement pstmt=null;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException cnfe){ }
try{
con1 = DriverManager.getConnection("jdbc:mysql://localhost/test","root","asecse");
stmt1 = con1.createStatement();
rs1 = stmt1.executeQuery("select *FROM student");
while(rs1.next()){
System.out.println(rs1.getString("name"));
}
}catch(SQLException sqle){ }
}}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment