Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication13;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class JavaApplication13 {
- public static void main(String[] args) {
- // TODO code application logic here
- String USERNAME="root";
- String PASSWORD="DXdhkNKQe0!*";
- String URL="jdbc:derby://localhost:1527/recipes";
- Connection connection=null;
- try{ // setting the PreparedStatement
- connection =
- DriverManager.getConnection( URL, USERNAME, PASSWORD );
- System.out.println("Works here too");}
- catch ( SQLException sqlException )
- { //error display, if SQL is not connected
- sqlException.printStackTrace();
- System.out.println("Error Found , check SQL is connected and working");
- System.exit( 1);
- }}
- }
- Result:
- run:
- java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/recipes
- Error Found , check SQL is connected and working
- at java.sql.DriverManager.getConnection(DriverManager.java:689)
- at java.sql.DriverManager.getConnection(DriverManager.java:247)
- at javaapplication13.JavaApplication13.main(JavaApplication13.java:25)
- /Users/killer/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: Java returned: 1
- BUILD FAILED (total time: 0 seconds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement