mardi 17 février 2015

How to Make JDBC Connection With SQL Server Express 2005 [on hold]

Help me to solve my issue


my code is



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class PrintFileToPrinter{

public static void main(String[] args){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String dbURL = " jdbc:sqlserver://TOSHIBA-PC/SQLEXPRESS:1433;databaseName=COSEC;user=sa;password=22484;";
Connection conn = DriverManager.getConnection(dbURL);
if (conn != null) {
System.out.println("Connected");
}
}catch(ClassNotFoundException | SQLException exception){
exception.printStackTrace();
}

}

}


and the error showing is



java.sql.SQLException: No suitable driver found for jdbc:sqlserver://TOSHIBA-PC/SQLEXPRESS:1433;databaseName=COSEC;user=sa;password=22484;
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at textfilemaker.PrintFileToPrinter.main(PrintFileToPrinter.java:19)


i am using sqljdbc4-2.0.jar my IDE is netbeans.


please help me in this issue and thanks in advance


Aucun commentaire:

Enregistrer un commentaire