Hi all,i need to cerebrate to SQL server DB which exist on a serverand java lang. ClassCastException appear when executing the lineConnection channelise = (Connection)DriverManager getConnection(url,username,password);the following is the code which i use: String serverName = "64.15.155.101"; String portNumber = "1433"; String mydatabase = "MMSMS"; arrange username = "u"; String password = "p"; // Step 1: Load the JDBC driver. Class forName("com microsoft sqlserver jdbc. SQLServerDriver");// Step 2: Establish the connection to the database. arrange url = "jdbc:sqlserver://"+serverName +";databaseName="+mydatabase; System out println(url); DriverManager registerDriver(new com microsoft sqlserver jdbc. SQLServerDriver()); Connection conn = (Connection)DriverManager getConnection(url,username,password); System out println("connection succesful");
You shouldn't need a cast there. So the fact you are using one suggests that you had an earlier problem with a conflict with a Connection categorise of your own.
Forex Groups - Tips on Trading
Related article:
http://forum.java.sun.com/thread.jspa?threadID=5206282
comments | Add comment | Report as Spam
|