Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection("jdbc:sqlserver:172.16.0.5//:1433; DatabaseName=Security", "pasw", "pasw");
These code works for couple months, and later on, it returns "java.sql.SQLException: No suitable driver" Error.
Then I download the jdbc driver from MS for SQL Server 2005, but it still return such errors.
Hey there try:
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
sqlCon = DriverManager.getConnection("jdbc:sqlserver://xxx.x.x.xxx:?;user=sa;password=~~~~##");
localhost:port
ipaddress:port
-You any idea how to connect to a particular database within the sql server. Once connected or is there a modification a ican apply to the string above?
Robert
|||I already tried your suggestion, but it doesn't workjava.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Stock_Report.ReadSymbol_SQLSERVER(Stock_Report.java:45)
at Stock_Report.main(Stock_Report.java:334)
|||The problem is that you need to add the driver jar file to your classpath somewhere. Most likely something changed the classpath and so Java cannot locate the driver.|||
Also, here is one sample way to connect using SQL 2005 driver:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://MySQLServer;user=MyUser;password=MyPassword;databaseName=MyDatabase;");
No comments:
Post a Comment