2

I have checked all messages with this issue but it's the same, It doesn't work. I have to connect to a sql server 2008 database with java, I have added the sqljdbc4.jar but nothing.

What I'm doing bad, if you need anything else, please, let me know.

 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
 conexion = DriverManager.getConnection("jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=ccis;user=isoft;password=1s0ft@");

I get this message:

java.sql.SQLException: No suitable driver found for jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=ccis;user=isoft;password=1s0ft@"

Could you help me?

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
zoit
  • 617
  • 2
  • 20
  • 41
  • check http://stackoverflow.com/questions/5616898/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmicrosoftsqlserver – Nandkumar Tekale Sep 03 '12 at 14:57
  • if you're 100% sure that the driver is correctly loaded in your classpath check the url connection string and the driver class name. – BigMike Sep 03 '12 at 14:58
  • I see a trailing semicolon in the driver [documentation](http://msdn.microsoft.com/en-us/library/ms378526.aspx). The semicolon is missing in your jdbc url. – randominstanceOfLivingThing Sep 03 '12 at 15:50
  • As a driver class name I have this: com.microsoft.sqlserver.jdbc.SQLServerDriver, and the URL connection is ok, so I don't know, what happen? – zoit Sep 03 '12 at 15:54
  • I have posted the semicolon as the documentation says and nothing – zoit Sep 03 '12 at 15:59
  • Note that sqljdbc4.jar requires JRE 6 or JRE 7 - and then you shouldn't need the call to Class.forName(). My suggestion would be to explicitly put in the -classpath parameter to the JVM with the sqljdbc.jar (not sqljdbc4.jar) at the start of the classpath. You can also use the -verbose Java option to ensure that the correct class is being loaded. – ifx Sep 10 '12 at 14:50

1 Answers1

0

Try to open a new instance of the driver and then connect to the database:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
conexion = DriverManager.getConnection("jdbc:sqlserver://xxx.xxx.xxx.xxx:1433" +
                        ";databaseName=ccis" +
                        ";user=isoft" + 
                        ";password=1s0ft@;");

Triple check if your sqljdbc4.jar is in your classapth.

Koshera
  • 439
  • 5
  • 14