Can't make jdbc working


#1

Dearl all,

we are trying to evaluate scidb for our internal projects.
I have successufully managed to start the database in a virtual machine (installing the rpm).
Now I am trying to connect to the db using jdbc and issueing some statements but I can’t really understand what I am doing wrong here.
Code is pretty simple:

	     try {
	        Class.forName("org.scidb.jdbc.Driver");
	     } catch (ClassNotFoundException e) {
	        System.out.println("Driver is not in the CLASSPATH -> " + e);
	    }

	    Connection conn = DriverManager.getConnection("jdbc:scidb://testhost/");
	    Statement st = conn.createStatement();

	    boolean er = st.execute("create array tiff<value:double> [lat_e4=-900000:900000,20000,0,lon_e4=-1800000:1800000,20000,0];");
	    System.out.println(er);
	    
	    conn.close();

In another thread I have understood that the jdbc is in “AQL mode” . After the execution I am expecting to find the tiff array on the database but:

AFL% list('arrays');
{No} name,id,schema,availability

Everything is working fine using iquery… am I missing something stupid?

thank you
g


#2

You’ve got a spurious “;” at the end of your query. Also, try the ‘executeQuery’ method instead of execute. This ran for me (replace host 192.168.0.80 with your SciDB testhost):

import org.scidb.jdbc.IResultSetWrapper;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

class Example
{
    public static void main(String [] args) throws IOException
    {
        try
        {
            Class.forName("org.scidb.jdbc.Driver");
        }
        catch (ClassNotFoundException e)
        {
            System.out.println("Driver is not in the CLASSPATH -> " + e);
        }

        try
        {
            Connection conn = DriverManager.getConnection("jdbc:scidb://192.168.0.80/");
            Statement st = conn.createStatement();
            ResultSet res = st.executeQuery("create array tiff<value:double> [lat_e4=-900000:900000,20000,0,lon_e4=-1800000:1800000,20000,0]");
        }
        catch (SQLException e)
        {
            System.out.println(e);
        }

        System.exit(0);
    }
}

Compile with:

javac -classpath scidb4j.jar JDBCExample.java

Run with:

java -classpath .:scidb4j.jar:/usr/share/java/protobuf-java.jar Example