public class Database_Control {
private Connection con;
private Statement statement;
private ResultSet res = null;
protected Connection database_connection(){
con = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/project","root","wppa241");
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
protected ResultSet select(String query){
con = database_connection();
try{
statement = con.createStatement();
res = statement.executeQuery(query);
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
return res;
}
protected void insert(String query){
con = database_connection();
try{
statement = con.createStatement();
statement.execute(query);
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
}
protected void update(String query){
con = database_connection();
try{
statement = con.createStatement();
statement.executeUpdate(query);
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
}
}
အဲ့ဒီ ကုဒ္ေလးေတြ ရမလားသိဘူး...
သူက connection ယူတယ္။ ၿပီးေတာ့ select, insert, update ေတြကို method ေတြခြဲေရးထားတယ္...
အရမ္းၾကီးေတာ့ မေရးတတ္ပါဘူး.. တတ္သေလာက္ မွတ္သေလာက္ေလး .. ေပါ့..
သီရိ