1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public class connexion{
public static void main (String args[]){}
private static Connection con = null;
public static Statement st;
public static ResultSet rs;
public static void connect(){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver ");
String stUrl = "jdbc:microsoft:sqlserver://hostname:PC-DE-ACER;" + "user=sa;DatabaseName=eagle";
con = DriverManager.getConnection("jdbc:sqlserver://localhost:PC-DE-ACER;databaseName=eagle;selectMethod=cursor" + "user=sa;password=;DatabaseName=eagle");
st=con.createStatement();
rs=st.executeQuery("select * from service");
System.out.println("ex.getMessage");}
catch(SQLException e) {
System.out.println(e.getMessage());
}
}} |