JDBC-SQLSERVER2000

xiaoxiao2021-03-06  43

Package zmsjdbc; import java.sql. *; public class sqlserver1 {

Private string url = "JDBC: Microsoft: SQL Server: // localhost: 1433; DatabaseName = CATV"; private string user = "sa"; private string pwd = ""; public connection getcon () {connection con; Load the driver class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInstance (); // Create a connection Con = DriverManager.getConnection (URL, User, PWD); Return Con;} catch (ClassNotNotNotNDException E) {System.out.Println ("Load Driver Error");} catch (sqlexception e) {system.out.println (E.GetMessage ());} catch (exception e) {system.out.println ("appears A big mistake ");

Return NULL;

Public ResultSet EXECUTESQL (String Sqlstr) {Connection Conn; Statement Stmt;

Try {conn = getCon (); stmt = conn.createstatement (); resultset = stmt.executeQuery (SQLSTR);

Return RS;} catch (sqlexception e) {system.out.print ("Errors when getting data set");} return null;}

public static void main ResultSet rs1 (String [] args) {; sqlserver1 sql1 = new sqlserver1 (); rs1 = sql1.executeSql ( "select ui_id, ui_name from userinfo"); try {while (rs1.next ()) {System .out.println ("UI_ID") "Name: rs1.getstring (" ui_name "));}}}} Catch (Exception E) {System.out.Println (E.getMessage ()); }}} / * 11:08 2005-2-24 -by beyond 1: For SQLServer must download SQL Server driver http://download/3/0/F/30FF65D3-A84B-4B8A-A570- 27366b2271d8 / setup.exe then copy the msbase.jar mssqlser.jar msutil.jar to D: /JBuilder9/JDK1.4/JRE/LIB/EXT 2: If an error occurs: java.sql.sqlexception: [Microsoft] [SQLServer 2000 Driver for JDBC] Error Establishing Socket.

Description SQlerver port number is not "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " = "JDBC: Microsoft: SQL Server: // localhost: 1433; DatabaseName = ZMSTV"; Description You use 1433 Enter netstat -a -n under CMD: TCP 127.0.0.1:1433 0.0.0:0:0 Listening * /

If you install SQLServer 2000 error error, "The previous program installation has been installed in the installation computer ..."

Open the Registry Editor, find the PENDINGFILERENAMEOPERATIONS project in HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / CONTROL / SESSION Manager and deletes it. This will clearly remove the installation.

转载请注明原文地址:https://www.9cbs.com/read-54178.html

New Post(0)