[Noob] Java / SQL Server 2005

L

Luc The Perverse

Here is my code (well here is the shortest version of the code which causes
the error)

import java.sql.*;

public class JDBCTest{
public static void main(String[] a) throws SQLException{ //port 1433? 1025?
Connection con = DriverManager.getConnection(

"jdbc:datadirect:sqlserver://127.0.0.1:1433;AuthenticationMethod=type2",

"sqluser","**********");


}
}

I have starred out the password, not that I don't trust you.

I get this error

E:\Documents and Settings\Luc\Desktop>java JDBCTest
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBCTest.main(JDBCTest.java:7)

What does this error mean? I have tried multiple examples of connecting to
an SQL database - all with identical results.

All I want to do is connect to my microsoft SQL server 2005 (free version)
on my local machine through TCP/IP. Right now the SQL server may be set up
for windows authentication, but that should be changeable. TCP IP
configurations are enabled, which is not default, though I was unsure of the
port, I found settings for two different ports, both of which I have tried.

SQL Server reports it is using a dynamic TCP port - I don't know what this
means either :( I cannot seem to find the appropriate Microsoft NG to
post questions specific to their server.
 
J

javajedi

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");

You need to load ODBC driver before getting a connection. SO your
source code should be:

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(...);
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

javajedi said:
public static void main(String[] a) throws SQLException{ //port 1433? 1025?
Connection con = DriverManager.getConnection(
"jdbc:datadirect:sqlserver://127.0.0.1:1433;AuthenticationMethod=type2",
"sqluser","**********");
E:\Documents and Settings\Luc\Desktop>java JDBCTest
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBCTest.main(JDBCTest.java:7)
What does this error mean? I have tried multiple examples of connecting to
an SQL database - all with identical results.
You need to load ODBC driver before getting a connection. SO your
source code should be:

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(...);

Correct cause of error, but with that URL he should be
using DataDirect driver not the JDBC-ODBC bridge. Or maybe
use Microsofts JDBC driver for SQLServer 2005.

For JDBC access this group or maybe better comp.lang.java.databases
is probably better.

Arne
 
T

TechBookReport

Arne said:
javajedi said:
public static void main(String[] a) throws SQLException{ //port
1433? 1025?
Connection con = DriverManager.getConnection(
"jdbc:datadirect:sqlserver://127.0.0.1:1433;AuthenticationMethod=type2",
"sqluser","**********");
E:\Documents and Settings\Luc\Desktop>java JDBCTest
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBCTest.main(JDBCTest.java:7)
What does this error mean? I have tried multiple examples of
connecting to
an SQL database - all with identical results.
You need to load ODBC driver before getting a connection. SO your
source code should be:

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(...);

Correct cause of error, but with that URL he should be
using DataDirect driver not the JDBC-ODBC bridge. Or maybe
use Microsofts JDBC driver for SQLServer 2005.

For JDBC access this group or maybe better comp.lang.java.databases
is probably better.

Arne

I agree, the MS SQL Server JDBC driver is the better choice. Details at:
http://msdn2.microsoft.com/en-us/data/aa937724.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top