I am using microsoft sql server2008 i download Microsoft SQL Server JDBC Driver 3.0 and i set the class path as C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\sqljdbc4.jar; and my program is
While compiling time no error but running time iam getting no suitable driver found for “jdbc:sqlserver:SQL1:sqlexpress;” +
please solve my issue.
Your connection String is invalid. It should be in the form jdbc:sqlserver://<HOST>:<PORT>;databaseName=<DATABASE> or jdbc:sqlserver://<HOST>\<INSTANCE>;databaseName=<DATABASE>, possibly followed by more parameters separated by semi-colons. The :<PORT> or \<INSTANCE> part can be omitted if you want to connect to the default instance on the default port (1433).
For you, assuming that you're using SQL Server Express and the instance name is SQLExpress, the connecting String becomes jdbc:sqlserver:/SQL1\SQLExpress;databaseName=MyDatabase. I wouldn't add the user name and password to the connection String; use the overloaded DriverManager.getConnection(connectionUrl, username, password) method for that.
Thank you very much my driver problem solved but still some errors.
while running time java Example
com.microsoft.sqlserver.jdbc.SQLserverConnection <init> SEVERE : Java Runtime Environment<JRE> version 106 is not supported by this driver. Use the sqljdbc4.jar class library,which provides support for JDBC 4.0. Java Runtime Environment <JRE> version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
How are you setting the classpath? I generally advise not to use the CLASSPATH variable, but the "-cp" switch. In that case, you'd enter something like:
java -cp theJdbcDriver.jar:. Example
posted 8 years ago
I have set the class path through -cp and set CLASSPATH also still iam getting same problem it showing only com.microsoft.sqlserver.jdbc.SQLServerDriver please check my code because iam new to development filed please help me to solve this problem.
What, exactly, are you typing to run the program? In which directory are you, and where are the class file and the jar file?
posted 8 years ago
I just running in command prompt only
to compile javac Example.java
run java Example
iam having my java file in desktop, my class file also created in desktop and jar file is in C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc4.jar