Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on my very first Java application that connects with MS SQL Server 2008, I have followed instructions on how to set classpaths( when using sqljdbc or jtds ), and how to configure JDBC-ODBC data sources either using the old SQL Server ODBC or SQL Server Native Client 10. then coded in java, when I try to establish a connection, I get the message like the one below

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


C#
try
        {
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            Class.forName( driver );

            String url = "jdbc:odbc:LoginTest";
            con = DriverManager.getConnection( url, "", "" );
            st = con.createStatement();
        }
        catch( Exception ex )
        {
            //JOptionPane.showMessageDialog( null, ex.getMessage() );
            System.err.println("SQL Exception : " + ex.getMessage() );
        }



Can someone please help me, I do not know what could be the problem because I have tried all the drivers but I still get the same message.
Thanx in advance!
Posted
Comments
Shubhashish_Mandal 19-Feb-13 8:46am    
Data source name is not created properly. However It is your first java application so I give you suggestion to use type 4 driver instead of Type 1(JDBC-ODBC Bridge).
Chief894 19-Feb-13 9:32am    
Oh yah thanx a lot, I managed to figure out the problem and found the solution. I realized I did a mistake at the Data source name as you stated, I was using the database name instead of the data source name

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900