由INET SOFTWARE 免费提供

豆豆的例程 a bean by inet's package


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 here
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);

// connection = DriverManager.getConnection(url,login,password);

// DatabaseMetaData conMD = connection.getMetaData();

// connection.setCatalog( "register");

} 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;
}
}
本站文章仅代表作者观点,本站仅传递信息,并不表示赞同或反对.转载本站点内容时请注明来自-Linux伊甸园。如不注明,将根据《互联网著作权行政保护办法》追究其相应法律责任。

--------------------next---------------------