mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Glenn Van Lint
19.15.2013 ce2ae76e2f2be42bbc651a58f23397b093718d2b
Create JDBCConnectionFactory class with connection test case. 
15 files added
1 files modified
229 ■■■■■ changed files
opendj3/opendj-virtual/.classpath 8 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/.project 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/.settings/org.eclipse.jdt.core.prefs 5 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/.settings/org.maven.ide.eclipse.prefs 7 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/pom.xml 5 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/JDBCConnectionFactory.java 96 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/JoinConnectionFactory.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/package-info.java 20 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/src/test/java/org/forgerock/opendj/virtual/Example.java 30 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/target/classes/org/forgerock/opendj/virtual/JDBCConnectionFactory.class patch | view | raw | blame | history
opendj3/opendj-virtual/target/classes/org/forgerock/opendj/virtual/package-info.class patch | view | raw | blame | history
opendj3/opendj-virtual/target/maven-archiver/pom.properties 5 ●●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst 1 ●●●● patch | view | raw | blame | history
opendj3/opendj-virtual/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst patch | view | raw | blame | history
opendj3/opendj-virtual/target/opendj-virtual-3.0.0-SNAPSHOT.jar patch | view | raw | blame | history
opendj3/opendj-virtual/target/test-classes/org/forgerock/opendj/virtual/Example.class patch | view | raw | blame | history
opendj3/opendj-virtual/.classpath
New file
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
opendj3/opendj-virtual/.project
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>opendj-virtual</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.maven.ide.eclipse.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.maven.ide.eclipse.maven2Nature</nature>
    </natures>
</projectDescription>
opendj3/opendj-virtual/.settings/org.eclipse.jdt.core.prefs
New file
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
opendj3/opendj-virtual/.settings/org.maven.ide.eclipse.prefs
New file
@@ -0,0 +1,7 @@
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1
opendj3/opendj-virtual/pom.xml
@@ -72,6 +72,11 @@
            <version>3.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/JDBCConnectionFactory.java
New file
@@ -0,0 +1,96 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS.
 */
package org.forgerock.opendj.virtual;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
 * Create a JDBC driver instance which contains all the methods for
 * connection and commands to the database.
 */
public class JDBCConnectionFactory {
    String driverName = "com.mysql.jdbc.Driver";
    Connection con = null;
    public JDBCConnectionFactory() {
            try {
                    Class.forName(driverName);
            } catch (ClassNotFoundException e) {
                    System.out.println(e.toString());
            }
    }
    /**
     * Set up a JDBC connection using the defined parameters.
     *
     * @param host
     *            The host address of the database.
     * @param port
     *            The port used to connect to the database.
     * @param databaseName
     *            The name of the database to connect with.
     * @param userName
     *            The username required for authentication to the database.
     * @param userPass
     *            The password required for authentication to the database.
     * @return The created connection.
     */
    public Connection createConnection(String host, String port, String databaseName, String userName, String userPass) {
            try {
                    String connectionUrl="jdbc:mysql://"
                                    .concat(host+":")
                                    .concat(port+"/")
                                    .concat(databaseName);
                    con = DriverManager
                                    .getConnection(connectionUrl,userName,userPass);
                    System.out.println("Connection created.");
                    } catch (SQLException e) {
                    System.out.println(e.toString());
            }
            return con;
    }
    /**
     * Close the open connection to the database.
     */
    public void closeConnection(){
            try{
                    this.con.close();
            System.out.println("Connection terminated.");
            }catch(Exception e){
                    System.out.println(e.toString());
            }
    }
}
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/JoinConnectionFactory.java
New file
@@ -0,0 +1,29 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS.
 */
package org.forgerock.opendj.virtual;
opendj3/opendj-virtual/src/main/java/org/forgerock/opendj/virtual/package-info.java
New file
@@ -0,0 +1,20 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012 ForgeRock AS.
 */
/**
 * APIs for the virtual directory.
 */
package org.forgerock.opendj.virtual;
opendj3/opendj-virtual/src/test/java/org/forgerock/opendj/virtual/Example.java
New file
@@ -0,0 +1,30 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2013 ForgeRock AS.
 */
package org.forgerock.opendj.virtual;
import org.forgerock.opendj.virtual.JDBCConnectionFactory;
/**
 * Example.
 */
public class Example {
     public static void main(String args[])throws Exception {
            final JDBCConnectionFactory JDBC =new JDBCConnectionFactory();
            JDBC.createConnection("localhost", "3306", "opendj_db","root", "");
            JDBC.closeConnection();
        }
}
opendj3/opendj-virtual/target/classes/org/forgerock/opendj/virtual/JDBCConnectionFactory.class
Binary files differ
opendj3/opendj-virtual/target/classes/org/forgerock/opendj/virtual/package-info.class
Binary files differ
opendj3/opendj-virtual/target/maven-archiver/pom.properties
New file
@@ -0,0 +1,5 @@
#Generated by Maven
#Mon Feb 18 15:53:05 CET 2013
version=3.0.0-SNAPSHOT
groupId=org.forgerock.opendj
artifactId=opendj-virtual
opendj3/opendj-virtual/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
New file
@@ -0,0 +1 @@
org\forgerock\opendj\virtual\JDBCConnectionFactory.class
opendj3/opendj-virtual/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
opendj3/opendj-virtual/target/opendj-virtual-3.0.0-SNAPSHOT.jar
Binary files differ
opendj3/opendj-virtual/target/test-classes/org/forgerock/opendj/virtual/Example.class
Binary files differ