package com.gaozhen.dbutils;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.Statement;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
public class Conn {
public static SQLServerConnection conn;
public static SQLServerConnection getconn() {
Statement sql;
ResultSet rs;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(Exception e){
System.out.println(e);
}
try{
String url="jdbc:sqlserver://localhost:1433;DatabaseName=GAOZHENBASE";
String user="newlogin";
String password="123456";
conn=(SQLServerConnection) DriverManager.getConnection(url,user,password);
// sql=conn.createStatement();
// rs=sql.executeQuery("select * from fruit");
// while(rs.next()){
// out.println(rs.getString("name"));
// out.println(rs.getString("price"));
// }
}catch(Exception e){
System.out.println(e);
}
return conn;
}
}
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.Statement;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
public class Conn {
public static SQLServerConnection conn;
public static SQLServerConnection getconn() {
Statement sql;
ResultSet rs;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(Exception e){
System.out.println(e);
}
try{
String url="jdbc:sqlserver://localhost:1433;DatabaseName=GAOZHENBASE";
String user="newlogin";
String password="123456";
conn=(SQLServerConnection) DriverManager.getConnection(url,user,password);
// sql=conn.createStatement();
// rs=sql.executeQuery("select * from fruit");
// while(rs.next()){
// out.println(rs.getString("name"));
// out.println(rs.getString("price"));
// }
}catch(Exception e){
System.out.println(e);
}
return conn;
}
}