Advertisement
Guest User

Untitled

a guest
Jun 1st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication13;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11. public class JavaApplication13 {
  12.  
  13.    
  14.     public static void main(String[] args) {
  15.         // TODO code application logic here
  16.           String USERNAME="root";
  17.  
  18.      String PASSWORD="DXdhkNKQe0!*";
  19.      String URL="jdbc:derby://localhost:1527/recipes";
  20.  
  21.          Connection connection=null;
  22.  try{ // setting the PreparedStatement
  23.  
  24.          connection =
  25.                 DriverManager.getConnection( URL, USERNAME, PASSWORD );
  26.                  System.out.println("Works here too");}
  27.  
  28.    
  29.      catch ( SQLException sqlException )
  30.      {  //error display, if SQL is not connected
  31.       sqlException.printStackTrace();
  32.             System.out.println("Error Found , check SQL is connected and working");
  33.             System.exit( 1);
  34.         }}
  35.    
  36. }
  37.  
  38. Result:
  39.     run:
  40. java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/recipes
  41. Error Found , check SQL is connected and working
  42.     at java.sql.DriverManager.getConnection(DriverManager.java:689)
  43.     at java.sql.DriverManager.getConnection(DriverManager.java:247)
  44.     at javaapplication13.JavaApplication13.main(JavaApplication13.java:25)
  45. /Users/killer/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: Java returned: 1
  46. BUILD FAILED (total time: 0 seconds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement