以IP与Port建立与SQLSERVER的连接_MySQL
package jsp;
import java.sql.*; // JDBC package
public class sql_data {
String url = "jdbc:inetdae:192.168.2.70?sql7=true"; // use your hostname and port number
String login = "sa"; // use your login here
String password =""; // use your password here
public Connection connection = null;
public Statement st = null;
public ResultSet rs = null;
public sql_data(){
try {
Class.forName("com.inet.tds.TdsDriver").newInstance();
DriverManager.setLoginTimeout(10);
} catch(Exception e) {
e.printStackTrace();
}
}
public void sqlclose() {
try {
st.close();
connection.close();
}
catch(SQLException ex) {
System.err.println("sqlclose: " + ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
try {
connection = DriverManager.getConnection(url,login,password);
connection.setCatalog( "register");
st = connection.createStatement();
rs = st.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}
推荐阅读
-
以IP与Port建立与SQLSERVER的连接_MySQL
-
以IP与Port建立与SQLSERVER的连接
-
PowerDesigner 建立与SQLSERVER 2005数据库的连接以便生成数据库和从数据库生成到PD中
-
PowerDesigner 建立与SQLSERVER 2005数据库的连接以便生成数据库和从数据库生成到PD中
-
Python3与SQLServer、Oracle、MySql的连接方法
-
php与mysql建立连接并执行SQL语句的代码
-
php与mysql建立连接并执行SQL语句的代码
-
Python3与SQLServer、Oracle、MySql的连接方法
-
sql if语句 php与mysql建立连接并执行SQL语句的代码
-
以IP与Port建立与SQLSERVER的连接_MySQL