Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Kết nối
- public class Conn {
- String url="";
- Connection conn;
- Statement st;
- public Conn(){}
- public void ConnectDB(String dbName)
- {
- try
- {
- url="jdbc:mysql://localhost/"+dbName;
- conn = DriverManager.getConnection(url, "root", "");
- st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
- System.out.println("Kết nối thành công !");
- }
- catch(Exception e)
- {
- System.out.println("Lỗi kết nối CSDL");
- }
- }
- public ResultSet Laydl(String tbName,String dk)
- {
- try
- {
- ResultSet rs;
- String sql="Select * From "+tbName+" Where "+dk;
- rs=st.executeQuery(sql);
- return rs;
- }
- catch(Exception e)
- {
- System.out.println("Lấy dl lỗi r");
- return null;
- }
- }
- }
- //ĐĂNG NHẬP
- public class Conn {
- String url="";
- Connection conn;
- Statement st;
- public Conn(){}
- public void ConnectDB(String dbName)
- {
- try
- {
- url="jdbc:mysql://localhost/"+dbName;
- conn = DriverManager.getConnection(url, "root", "");
- st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
- System.out.println("Kết nối thành công !");
- }
- catch(Exception e)
- {
- System.out.println("Lỗi kết nối CSDL");
- }
- }
- public ResultSet Laydl(String tbName,String dk)
- {
- try
- {
- ResultSet rs;
- String sql="Select * From "+tbName+" Where "+dk;
- rs=st.executeQuery(sql);
- return rs;
- }
- catch(Exception e)
- {
- System.out.println("Lấy dl lỗi r");
- return null;
- }
- }
- }
- //DSCV
- private void formWindowOpened(java.awt.event.WindowEvent evt) {
- // TODO add your handling code here:
- buttonGroup1.add(rdbKTTG);
- buttonGroup1.add(rdbPTBN);
- buttonGroup1.add(rdbSoHoanThien);
- buttonGroup1.add(rdbUCLN);
- }
- private void btnDisplayActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- if(rdbUCLN.isSelected()==true)
- {
- FormUCLN frm = new FormUCLN();
- frm.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement