publicclass JDBCConnectionExample {
publicstaticvoid main(String[] args) {
// TODO Auto-generated method stub
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=NovaBaza;integratedSecurity=false;us er=sa;password=javajdbc";
// Declare the JDBC objects.
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns a
// set of data and then display it.
//String SQL = "SELECT * FROM BLOBTest;";
//stmt = con.createStatement();
//rs = stmt.executeQuery(SQL);
//displayRow("Ident", rs);
// Handle any errors that may have occurred.
if (rs != null) try { rs.close(); } catch(Exception e) {}
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
if (con != null) try { con.close(); } catch(Exception e) {}
//private static void displayRow(String title, ResultSet rs) {
/// System.out.println(title);
// System.out.println(rs.getString());
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at JDBCConnectionExample.main(JDBCConnectionExample.java:22)