get derby DB Connection - Java java.sql

Java examples for java.sql:Derby

Description

get derby DB Connection

Demo Code


import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main{
    public static Connection getDBConnection() throws SQLException,
            ClassNotFoundException {
        Class.forName("org.apache.derby.jdbc.ClientDriver");
        Driver myDriver = new org.apache.derby.jdbc.ClientDriver();
        DriverManager.registerDriver(myDriver);
        return DriverManager
                .getConnection("jdbc:derby://localhost:1527/Score");
    }/*from w  w w .  j  av  a2 s.co m*/
}

Related Tutorials