连接SQL Server - Java

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Test {
 private Connection conn;
 private String CLASSFORNAME=com.microsoft.sqlserver.jdbc.SQLServerDriver";
 private String url ="jdbc:sqlserver://127.0.0.1:1433;databaseName=framework";
 private String user="sa";
 private String password="";

boolean ConnectionDataBase() 
 {  

    Properties sysProps = System.getProperties();
    sysProps.put("user",user);
    sysProps.put("password",password);
     try
    {    
    Class.forName(CLASSFORNAME);
    conn= DriverManager.getConnection(url, sysProps);
    return true;  
    }    
  catch(Exception e)
  {
   e.printStackTrace();
   return false;
  }
 }

}

 

 

//"com.microsoft.jdbc.sqlserver.SQLServerDriver""

你可能感兴趣的:(sql,exception,String,server,properties,user,sqlserver)