????SQL Server???????
???????????? ???????[ 2015/5/14 14:42:42 ] ?????????????
??????????????????Sqlserver?????????????Sqlserver?????????????????????????????????д?????????
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class sqlServer {
ResultSet rs=null;
//????????????????
String url="jdbc:sqlserver://localhost:1433;databaseName=Pet";
String DriverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
//???????
String userName="sa";
//?????????
String password="123";
//????????????????
public Connection getConnection(){
//????????
try {
Class.forName(DriverClassName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Connection con =null;
//??????????
try {
con =DriverManager.getConnection(url??userName??password);
System.out.println("?????????????");
//?????????
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
//======??????????=======
public void ShiFang(ResultSet rs?? Statement st??Connection con){
//????????????????????? ?????????
try {
if(rs!=null){
rs.close();
}if(st!=null){
st.close();
}if(con!=null){
con.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11