Creating Connection To Mysql: Try Catch (Exception E)
Creating Connection To Mysql: Try Catch (Exception E)
# R.C on Project Folder -> Properties, Click on Java Build Path, Click on Add JARs. Select driver in lib
import java.sql.*;
try{
}
catch(Exception e){
}
Connection to MySQL DB
Connection con1 =
DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name_optional","root","");
Creating statement
Statement st1= con1.createStatement();
Executing statement
ResultSet result = st1.executeQuery("Select * from student");
Displaying result
while(result.next()){
System.out.println(result.getString("Col1")+result.getString("Col2")+result.getSt
ring("Col3"));
}