package connection;
import java.sql.*;
public class MysqlCon {
public static void main(String[]args)
{
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3307/prince","root","root");
System.out.println("Connection etaiblish");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * FROM emp");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getInt(2)+""+rs.getString(3)+""+rs.getInt(4)+"");
con.close();
}
catch(ClassNotFoundException e) {
System.out.println("exception="+e.getMessage());
}
catch(SQLException e) {
System.out.println("exception="+e.getMessage());
}
}
import java.sql.*;
public class MysqlCon {
public static void main(String[]args)
{
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3307/prince","root","root");
System.out.println("Connection etaiblish");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * FROM emp");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getInt(2)+""+rs.getString(3)+""+rs.getInt(4)+"");
con.close();
}
catch(ClassNotFoundException e) {
System.out.println("exception="+e.getMessage());
}
catch(SQLException e) {
System.out.println("exception="+e.getMessage());
}
}
}
0 comments:
Post a Comment