HOW TO: ????? ??? ?? JDBC Microsoft

?????? ????????? ?????? ?????????
???? ???????: 313100 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ??????? ?? SQL Server 2000 ???????? ?????? ????? Microsoft SQL Server 2000 JDBC.


??????: ?????? ??? ??????? ??????? ??????? Microsoft SQL Server 2000 ????? ?? JDBC ? ???? Microsoft SQL Server 2000 ????? ?? JDBC ???? ???????.

??? ????? ?????? ????? Microsoft SQL Server 2000 ?? JDBC ????? ??????? ?? ???????? ????? ???????? ????????: ???????? ???? ???? ??????? ????? ?? ???????? ???? ?????? JNDI. ???? ??? ??????? ????? ????? ?????? ????? ????? ???????? ???????? ???? ???? ??????? ?????.

????? ????? ?? ??????? ?????? ?????? ???? "????? ?????? ??????? JDBC ?????? ??????? ??????? getConnection ??? DriverManager. ??????? ???? ?? ??????? ??? ??????? ???? ????? ????? ????? ??? URL ??? ?????? ????? ????. ??? ??????? ??????? ?? ??? ??????? ????? ????? ?????? ????? Microsoft SQL Server 2000 JDBC ?? ?????? JDBC.

????? ????? CLASSPATH

??? ?? ??? ??? ?????? ????? Microsoft SQL Server 2000 ?????? .jar JDBC ?? ????? CLASSPATH. ????? CLASSPATH ?? ????? ????? ???? ??????? ???? ????? Java (JVM) ????? ???? ????? ??????? JDBC ??? ???? ????????? ????? ??. ??? ?? ??? ??? ????? ??????? ?? ????? CLASSPATH ? ????? ????? ????? ??????? ??? ?????? ????? ?????? ???????:
java.lang.ClassNotFoundException: com/microsoft/jdbc/sqlserver/SQLServerDriver
????? ????? CLASSPATH ?????? ????? ?? ????? ????????? ???????:
  • \ \Lib\Msbase.jar Your installation path
  • \ \Lib\Msutil.jar Your installation path
  • \ \Lib\Mssqlserver.jar Your installation path
??? ???? ?? ????? CLASSPATH ???????:
CLASSPATH =.; files\Microsoft c:\program SQL Server 2000 ????? files\Microsoft JDBC\lib\msbase.jar;c:\program SQL Server 2000 ????? files\Microsoft JDBC\lib\msutil.jar;c:\program SQL Server 2000 ????? ?? JDBC\lib\mssqlserver.jar

??? ????? ?????? ???????

????? ?????? ??????? ????? JDBC ????? ????? ????? ?????? ??????? ???????. ??? ????? ?????? ????? ???????? ?????? class.forName ??? ????? ??? ?????? ???????. ??? ?? ??? ?????? ??????? ??????? Microsoft SQL Server 2000 ?? JDBC:
com.microsoft.jdbc.sqlserver.SQLServerDriver
???? ????? ????????? ???????? ?????? ????? ????? ?????? ???????:
Driver d = (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
				

??? ????? URL ?????

??? ?? ??? ??????? ????? ????? ???????? ?????? ?? ?? ????? ???? ???? ??????? ???????. ??? ?? URL ???? ??????? Microsoft SQL Server 2000 ?? JDBC. ??????? ??? ????? ???????? ?????? ??:
jdbc:microsoft:sqlserver: / / servername:1433
???? ????? ????????? ???????? ?????? ????? ????? URL ?????:
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433", "userName", "password");
				
??? ??? ?????? ???? ?? ???? ????? IP ?? ??? ???? (?? ?????? ?? ???? ??????? ??? ?? ????? ???????? ??? ?????? IP). ????? ?????? ??? ?? ???? ????? ????? ping ???? ??? ?????? ??????? ?? ???? ?? ?? ????? IP ??????.

???? ????? ??? ??? ?????? ?? ??? ?????? ???? ????? ????? ????????. ?? ????? ???? ?? ????? ?????? ?? ??? ??????? ????? ?????????? ??????. ???? ?? ??????? ??? ?????? ???? ?????? ????? ????????.

?????? ??? ????? ????? ?????? URL ????? ???? ?????? ?? Microsoft SQL Server 2000 ????? ??????? HTML JDBC ?? ???? ???? ??????. ???? ?????? "????? ????? ?????".

????? ????? ??? ?????? ?????

????? ????????? ???????? ?????? ????? ??????? ?????? ?????? ???? ??? ????? ???????? "?" ??????? "?" ??????? ??????? ??????. ??????? ????? ???? ???? ??????:
import java.*;
public class Connect{
     private java.sql.Connection  con = null;
     private final String url = "jdbc:microsoft:sqlserver://";
     private final String serverName= "localhost";
     private final String portNumber = "1433";
     private final String databaseName= "pubs";
     private final String userName = "user";
     private final String password = "password";
     // Informs the driver to use server a side-cursor, 
     // which permits more than one active statement 
     // on a connection.
     private final String selectMethod = "cursor"; 
     
     // Constructor
     public Connect(){}
     
     private String getConnectionUrl(){
          return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";
     }
     
     private java.sql.Connection getConnection(){
          try{
               Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 
               con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);
               if(con!=null) System.out.println("Connection Successful!");
          }catch(Exception e){
               e.printStackTrace();
               System.out.println("Error Trace in getConnection() : " + e.getMessage());
         }
          return con;
      }

     /*
          Display the driver properties, database details 
     */ 

     public void displayDbProperties(){
          java.sql.DatabaseMetaData dm = null;
          java.sql.ResultSet rs = null;
          try{
               con= this.getConnection();
               if(con!=null){
                    dm = con.getMetaData();
                    System.out.println("Driver Information");
                    System.out.println("\tDriver Name: "+ dm.getDriverName());
                    System.out.println("\tDriver Version: "+ dm.getDriverVersion ());
                    System.out.println("\nDatabase Information ");
                    System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());
                    System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());
                    System.out.println("Avalilable Catalogs ");
                    rs = dm.getCatalogs();
                    while(rs.next()){
                         System.out.println("\tcatalog: "+ rs.getString(1));
                    } 
                    rs.close();
                    rs = null;
                    closeConnection();
               }else System.out.println("Error: No active Connection");
          }catch(Exception e){
               e.printStackTrace();
          }
          dm=null;
     }     
     
     private void closeConnection(){
          try{
               if(con!=null)
                    con.close();
               con=null;
          }catch(Exception e){
               e.printStackTrace();
          }
     }
     public static void main(String[] args) throws Exception
       {
          Connect myDbTest = new Connect();
          myDbTest.displayDbProperties();
       }
}

				
??? ???? ??? ???????? ???????? ??????? ??????? ????? ??? ???:
Connection Successful!
Driver Information
        Driver Name: SQLServer
        Driver Version: 2.2.0022

Database Information
        Database Name: Microsoft SQL Server
        Database Version: Microsoft SQL Server  2000 - 8.00.384 (Intel X86)
        May 23 2001 00:02:52
        Copyright (c) 1988-2000 Microsoft Corporation
        Desktop Engine on Windows NT 5.1 (Build 2600: )

Avalilable Catalogs
        catalog: master
        catalog: msdb
        catalog: pubs
        catalog: tempdb
					

??????? ????? ????? ??????

??? ?? ????? ????? ??????? ???? ?? ???? ??? ?????? ??????? ????? SQL:
java.sql.SQLException: [Microsoft] [SQLServer ????? 2000 ?? JDBC] ??? ????? ?????? [SQLServer] ?????? '????????'. ?????: ??????? ??? ????? SQL Server ????? ??.
???? ????? ????? ??? ??? ?? ????? ??? ?????? SQL Server 2000 ??? ??? ?????? Windows. ?? ????? ?????? ????? Microsoft SQL Server 2000 JDBC ??????? ???????? ?????? Windows NT. ??? ????? ??? ?????? ???? SQL ??? ??? ?????? ???? ?? ?? "?????? Windows" ? "?????? ???? SQL.
java.sql.SQLException: [Microsoft] [SQLServer ????? 2000 ?? JDBC] ????? ??? ??????? ?? ?????? ??????? JDBC Microsoft SQL Server 2000 ???. ????? ??????? ??? SQL Server 2000 "?? ?? ??????? ?? ???? ???? ??? ????? ?? ?????? ???????.
???? ????? ????? ??? ?? ?????? ??????? ????? SQL Server ?????? ?? SQL Server 2000. ???? ?????? ????? Microsoft SQL Server 2000 JDBC ??????? ??? ?? SQL Server 2000.

???????

???? ???????: 313100 - ????? ??? ??????: 17/?? ??????/1424 - ??????: 3.3
????? ???
  • Microsoft SQL Server 2000 Driver for JDBC
  • Microsoft SQL Server 2000 64-bit Edition
  • Microsoft SQL Server 2000 Standard Edition
????? ??????: 
kbmt kbhowtomaster KB313100 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????313100

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com