本人初学
用jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe
想连接SQL Server2000 已打sp4补丁配置了
JAVA_HOME “C:\Program Files\Java\jdk1.6.0_10”
PATH “%JAVA_HOME%\bin”
CLASS_PATH “.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;C:\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\chs\sqljdbc4.jar;”在 C:\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\chs\help\samples\connectionsconnectURL.java 代码如下import java.sql.*;public class connectURL { public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=pubs;integratedSecurity=true;"; // Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns some data.
String SQL = "SELECT TOP 10 * FROM Person.Contact";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
// Iterate through the data in the result set and display it.
while (rs.next()) {
System.out.println(rs.getString(4) + " " + rs.getString(6));
}
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
} finally {
if (rs != null) try { rs.close(); } catch(Exception e) {}
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
if (con != null) try { con.close(); } catch(Exception e) {}
}
}
}java connectURL.java 成功
运行 java connectURL 抛出 ClassNotFoundExceprion 异常
com.microsoft.sqlserver.jdbc.SQLServerDriver本人初学,请问我该怎么来配置啊?
先不说用MyEclipse8.5怎么来连接
想知道只有JDBC驱动 和 JDK 时候怎么来连接啊?
用jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe
想连接SQL Server2000 已打sp4补丁配置了
JAVA_HOME “C:\Program Files\Java\jdk1.6.0_10”
PATH “%JAVA_HOME%\bin”
CLASS_PATH “.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;C:\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\chs\sqljdbc4.jar;”在 C:\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\chs\help\samples\connectionsconnectURL.java 代码如下import java.sql.*;public class connectURL { public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=pubs;integratedSecurity=true;"; // Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns some data.
String SQL = "SELECT TOP 10 * FROM Person.Contact";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
// Iterate through the data in the result set and display it.
while (rs.next()) {
System.out.println(rs.getString(4) + " " + rs.getString(6));
}
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
} finally {
if (rs != null) try { rs.close(); } catch(Exception e) {}
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
if (con != null) try { con.close(); } catch(Exception e) {}
}
}
}java connectURL.java 成功
运行 java connectURL 抛出 ClassNotFoundExceprion 异常
com.microsoft.sqlserver.jdbc.SQLServerDriver本人初学,请问我该怎么来配置啊?
先不说用MyEclipse8.5怎么来连接
想知道只有JDBC驱动 和 JDK 时候怎么来连接啊?
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
if(cdr_db_conn != null && !cdr_db_conn.isClosed()) {
cdr_db_conn.close();
}
cdr_db_conn=null;
String dbUrl="jdbc:oracle:thin:@" + cdr_database_ip + ":1521:" + cdr_database_name;
cdr_db_conn = DriverManager.getConnection(dbUrl, cdr_database_user, cdr_database_passwd);
logger.debug("CDR DATABASE:" + dbUrl + " Connection success!");
}catch(Exception se) {
System.exit(0);
}
return true;
}
希望对你有帮助
谢谢了我下的是sqljdbc.jar 和 sqljdbc4.jar 这2个不能用吗?