import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
Connection con;
preparedStatment pstmt;
ResultSet ts;
//1.Connect with DB
con = DriverManager.getConnection(
"jdbc:mysql://(DB address)",
"(sqlid)",
"(sqlpassword)"
);
//2.Interact with db
pstmt = don.preparedStatement (sql statement);
//3.Execution of select statement and substitution of result
rs.pstmt.executeQuery();
//4.View results
while(rs.next()){
}catcg(SQLException e){
e.printStackTrace();
}fainally{
DB close process
}
Recommended Posts