tags:

views:

64

answers:

1

i used this code in a small demo project. but really whats the different between Jconnection package from shine pattern and the JDBC

package mypackage;

import org.j2os.shine.jconnection.*;

import java.sql.ResultSet;

    public class Class1{
        public static void main(String[] args) throws Exception {
            JDBC mydb = new JDBC();
            System.out.println(mydb.login("com.mysql.jdbc.Driver",
                    "jdbc:mysql://localhost/test", "root", "root", true));
            mydb.executeSQLQuery("insert into product (name) values ('test')");
            mydb.commit();
        //////////////////////////////////////////////////////////////////
        mydb.login("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test",
            "root", "root", true);

        ResultSet r = mydb.getSQLQueryContent("select * from product");

        while (r.next()) {
            System.out.println(r.getString("name"));
        }

        mydb.commit();
    }
}
+1  A: 

I have not used it, but a quick look shows that JConnection aims to take some of the drugery out of JDBC. In other words, JDBC is a low-level API for interacting with SQL databases, and JConnection is a higher-level library.

In your example, there is no JDBC Statement, nor Connection. Managing these, and remembering to close them, even in the face of exceptions, getting the correct statement type etc. can be a pain for newcommers as well as and old hands of JDBC.

There are many frameworks that make working directly to JDBC unnecessary (iBatis, Hibernate, etc...) but if you have to code to JDBC directly, JConnection will reduce the amount of boilerplate you have to write.

EDIT: From the user guide:

What is JConnection? JConnection is a tool for developers at the DB layer that solve lots of amateurs’ problems. This tool helps you to work with JDBC and Hibernate. JDBC Class This class helps you to less engagement with Statement and Connectionin entities in JDBC.

mdma