Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package baitap;
- import java.sql.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author Po
- */
- public class SQLConnection {
- String connectionUrl = "jdbc:sqlserver://localhost:1189;" +
- "databaseName=TestConnection;user=sa;password=1";
- Connection con = null;
- public Connection KetNoi ()
- {
- try {
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- con = DriverManager.getConnection(connectionUrl);
- if(con!= null)
- System.out.println("done");
- con.close();
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(SQLConnection.class.getName()).log(Level.SEVERE, null, ex);
- } catch (SQLException ex) {
- System.out.println("aaa");
- }
- }
- }
Add Comment
Please, Sign In to add comment