JConnection
Posted by: ammar bozorgvar
Date: August 02, 2010 01:24PM

hi
i used JConnection Package from shine enterprise java pattern to connect to data base from a java program.
i feel its more clear.
pleas tel me your idea about it if there is any way to make the code shorter.

package db;

import org.j2sos.shine.jconnection.*;
import java.sql.ResultSet;

public class DAO {

public static void main(String[] args) throws Exception {

JDBC mydb = new JDBC();

System.out.println(mydb.login("com.mysql.jdbc.Driver",
"jdbc:mysql://localhost/j2sos", "root", "mypassword", true));

mydb.executeSQLQuery("insert into product (name) values ('test')");

mydb.commit();

//////////////////////////////////////////////////////////////////

mydb.login("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/j2sos",
"root", "mypassword", true);

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

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

mydb.commit();
}
}

Options: Reply• Quote


Subject
Written By
Posted
JConnection
August 02, 2010 01:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.