Ask Experts Questions for FREE Help !
Ask
    sushilshingote's Avatar
    sushilshingote Posts: 1, Reputation: 1
    New Member
     
    #1

    Sep 29, 2013, 04:50 AM
    Getting ClassNotFoundException while connecting with server side SQL database
    While connecting with SQL server database which is located at server computer from local computer, I am getting ClassNotFoundException. I wrote following code to connect with SQL server in java:-

    import java.sql.*;

    public class ConnectDatabase {

    Connection dbConnection = null;

    String dbName = "Radiocity_Central";
    String serverip="192.168.69.189";
    String serverport="1433";
    String url = "jdbc:sqlserver://192.168.69.189:1433;instance=MSRS11.MSSQLSERVER;Da tabaseName=Radiocity_Central;integratedSecurity=tr ue";
    String userName = "sa";
    String password = "airwaves";
    final String driverName = "com.microsoft.sqlserver.jdbc.Radiocity_Centra l";
    Statement statement = null;
    ResultSet rs = null;
    int updateQuery = 0;

    public Connection getConnection() {

    System.out.println(url);
    try{
    Class.forName(driverName).newInstance();

    dbConnection = DriverManager.getConnection(url,userName,password) ;
    System.out.println(DriverManager.getDrivers());

    statement = dbConnection.createStatement();

    /*String QueryString = "select Id from openview.dbo.OV_MS_Message where OriginalServiceId like '{FaultDn[1]}'";

    updateQuery = statement.executeUpdate(QueryString);

    if(updateQuery!=0){
    System.out.println("success" + updateQuery);
    }*/
    statement.close();
    dbConnection.close();
    }
    catch (ClassNotFoundException cnfe){
    cnfe.printStackTrace();
    }
    catch (Exception e){
    e.printStackTrace();
    }
    return dbConnection;

    }

    public static void main(String[] args) {

    ConnectDatabase cDB = new ConnectDatabase();
    cDB.getConnection();

    }

    }

    The runtime exception which I am getting is given below:-

    jdbc:sqlserver://192.168.69.189:1433;instance=MSRS11.MSSQLSERVER;Da tabaseName=Ra
    diocity_Central;integratedSecurity=true
    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.Radiocity_Central

    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at ConnectDatabase.getConnection(ConnectDatabase.java :22)
    at ConnectDatabase.main(ConnectDatabase.java:52)

    Please help me to solve this problem.
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #2

    Dec 2, 2013, 03:15 AM
    Begin by reading How to resolve java.lang.ClassNotFoundException in Java and How to Resolve java.lang.ClassNotFoundException.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Sql database connectivity [ 1 Answers ]

Database connectivity with server

Excel - Importing from web or SQL database? [ 5 Answers ]

Ok, I know how to Import from the Web via Excel.. that is not what I am looking for. Here is what I would like to be able to do: We have a system that we can upload a pre-formatted PDF with variables that will pull info from our system. This works great for populating customized contracts. ...

Update of SQL Server database content [ 1 Answers ]

I have database in the web with SQL Server 7.0. Now how can I periodically update the content of the database by simply uploading text file containing the cumulative updates? Can anyone help?


View more questions Search