git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@85289 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3285020ed8
commit
46e4be0a67
|
@ -12,8 +12,6 @@ import java.sql.Statement;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
@ -35,6 +33,7 @@ public class DBTester {
|
|||
|
||||
|
||||
public static void main(String[] a) throws Exception {
|
||||
|
||||
Class.forName("org.h2.Driver");
|
||||
Connection conn = DriverManager.getConnection("jdbc:h2:/home/francesco-mangiacrapa/Portal-Bundle2.2/tomcat-6.0.29/persistence/h2dbspecies/h2testusergcubedevsec;create=true", "","");
|
||||
// add application code here
|
||||
|
@ -61,20 +60,40 @@ public class DBTester {
|
|||
System.out.println("\n\n");
|
||||
}
|
||||
conn.close();
|
||||
|
||||
// testJdbcDataSource();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void getConnection() throws NamingException {
|
||||
public static void testJdbcDataSource() throws NamingException {
|
||||
|
||||
JdbcDataSource ds = new JdbcDataSource();
|
||||
ds.setURL("jdbc:h2:/home/francesco-mangiacrapa/Portal-Bundle2.2/tomcat-6.0.29/persistence/h2dbspecies/h2testusergcubedevsec;create=true");
|
||||
Context ctx = new InitialContext();
|
||||
ctx.bind("jdbc/h2testusergcubedevsec", ds);
|
||||
// Context ctx = new InitialContext();
|
||||
// ctx.bind("jdbc/h2testusergcubedevsec/TaxonomyRow.class", ds);
|
||||
try {
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
conn.createStatement().execute("Select * from TaxonomyJob");
|
||||
Connection conn = ds.getConnection();
|
||||
ResultSet rs = conn.createStatement().executeQuery("select * from TaxonomyRow");
|
||||
ResultSetMetaData meta = rs.getMetaData();
|
||||
int columnCount = meta.getColumnCount();
|
||||
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
System.out.println("New row");
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
|
||||
// System.out.println("ColumName: "+ meta.getColumnName(i));
|
||||
System.out.println("ColumLabel: "+meta.getColumnLabel(i));
|
||||
System.out.println(rs.getString(meta.getColumnLabel(i)));
|
||||
|
||||
}
|
||||
|
||||
System.out.println("\n\n");
|
||||
}
|
||||
conn.close();
|
||||
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
Reference in New Issue