Hi,
I'm trying to connect to the Monetdb using Java on Linux (Ubuntu 7.04/i386).

I used the example java program given on the MonetDB site.
$ javac -cp jdbcclient-1.6.jar:. MJDBCTest.java
$ java -cp jdbcclient-1.6.jar:. MJDBCTest

I'm getting a persistent error:.
Exception in thread "main" java.sql.SQLException:
java.net.URISyntaxException: Expected scheme name at index 0:
:monetdb://127.0.0.1:50002/mytest2?lang=sql&user=monetdb
        at nl.cwi.monetdb.jdbc.MonetConnection.<init>(MonetConnection.java:217)
        at nl.cwi.monetdb.jdbc.MonetDriver.connect(MonetDriver.java:157)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at MJDBCTest.main(MJDBCTest.java:14)

The Java code is attached below for reference:

import java.sql.*;^M
public class MJDBCTest {^M
        public static void main(String[] args) throws Exception {^M
                // make sure the driver is loaded^M
                Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");^M
                Connection con =
DriverManager.getConnection("jdbc:monetdb://localhost/mytest2",
"monetdb", "monetdb");^M
                Statement st = con.createStatement();^M
                ResultSet rs;^M
^M
                rs = st.executeQuery("SELECT * from foobar");^M
                // get meta data and print columns with their type^M
                ResultSetMetaData md = rs.getMetaData();^M
                for (int i = 1; i <= md.getColumnCount(); i++) {^M
                        System.out.print(md.getColumnName(i) + ":" +^M
                                md.getColumnTypeName(i) + "\t");^M
                }^M
                System.out.println("");^M
                // print the data: only the first 5 rows, while there
probably are^M
                // a lot more. This shouldn't cause any problems
afterwards since the^M
                // result should get properly discarded on the next query^M
                for (int i = 0; rs.next() && i < 5; i++) {^M
                        for (int j = 1; j <= md.getColumnCount(); j++) {^M
                                System.out.print(rs.getString(j) + "\t");^M
                        }^M
                        System.out.println("");^M
                }^M
^M
                // tell the driver to only return 5 rows, it can
optimize on this^M
                // value, and will not fetch any more than 5 rows.^M
                //st.setMaxRows(5);^M
                // we ask the database for 22 rows, while we set the
JDBC driver to^M
                // 5 rows, this shouldn't be a problem at all...^M
                rs = st.executeQuery("select * from foobar  limit 2");^M
                // read till the driver says there are no rows left^M
                for (int i = 0; rs.next(); i++) {^M
                        System.out.print("[" + rs.getString(1) + "]");^M
                        System.out.print("[" + rs.getString(2) + "]\n");^M
                        ^M
                }^M
                con.close();^M
        }^M
}

-- 
Home: http://btbytes.com
Heart: http://sampada.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
MonetDB-users mailing list
MonetDB-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-users

Reply via email to