Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Im having difficulty connecting my sqlite database to my netbeans application. Once i run the code below i get the error

/Users/lm/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:48:
Cancelled by user.
BUILD FAILED (total time: 1 second)

I have also imported the jar file into the library called sqlite-jdbc 3.6.13 jar and installed the sqlite plugin.

What I have tried:

I have also imported the jar file into the library called sqlite-jdbc 3.6.13 jar and installed the sqlite plugin.

Code

import java.sql.*;

public class ConnecttoDB
{
public static void main( String args[] )
{
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:/Users/lm/Documents/JavaProject.sqlite");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900