Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

connect sqlite for java

package net.sqlitetutorial;

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

/**
 *
 * @author sqlitetutorial.net
 */
public class Connect {
     /**
     * Connect to a sample database
     */
    public static void connect() {
        Connection conn = null;
        try {
            // db parameters
            String url = "jdbc:sqlite:C:/sqlite/db/chinook.db";
            // create a connection to the database
            conn = DriverManager.getConnection(url);
            
            System.out.println("Connection to SQLite has been established.");
            
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        } finally {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException ex) {
                System.out.println(ex.getMessage());
            }
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        connect();
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to check base64 in java 
Java :: list of integers in java 
Java :: how to find max in min in an array 
Java :: java math power 
Java :: flutter java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 
Java :: initialize applet in java 
Java :: java not equals string 
Java :: get the length of an array java 
Java :: android studio download 
Java :: immutable map java 
Java :: java char array to string 
Java :: java sort int array 
Java :: java string array to arraylist 
Java :: reverse in jaav 
Java :: read timed out android studio 
Java :: java using .indexof to fin a space 
Java :: linear search java 
Java :: importing all java libraries 
Java :: different types of variables in java 
Java :: android java shared preferences remove key 
Java :: java find if element of list in present in another list 
Java :: Java heap retention in BodyContentImpl 
Java :: how to make a dictionary in java 
Java :: cors spring 
Java :: java get jar execution directory 
Java :: java lb to kg 
Java :: jmeter get var 
Java :: recursion examples java 
Java :: button onclick java 
Java :: java append to file 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =