Hi Madhu,
Are you using the Virtuoso open source or commercial product on windows, as the
JDBCDemo.bat ?
Below is a sample program showing how a basic JDBC connection can be made and
data retrieved from the Virtuoso RDF store:
$ more sample.java
import java.io.*;
import java.lang.*;
import java.util.Properties;
import java.sql.*;
class sample
{
public static void PrintField (String name)
{
if (name == null)
name = "NULL";
System.out.print (name + " ");
}
public static void
ExecuteQuery (Connection conn, String query)
throws Exception
{
ResultSetMetaData meta;
Statement stmt;
ResultSet result;
int count;
System.out.println ("EXECUTE: " + query);
stmt = conn.createStatement ();
result = stmt.executeQuery (query);
meta = result.getMetaData ();
count = meta.getColumnCount ();
for (int c = 1; c <= count; c++)
PrintField (meta.getColumnName (c));
System.out.println ("\n--------------");
while (result.next())
{
for (int c = 1; c <= count; c++)
PrintField (result.getString (c));
System.out.println ("");
}
stmt.close ();
System.out.println ("");
}
public static void main (String argv[])
throws Exception
{
Class.forName("virtuoso.jdbc3.Driver");
Connection conn =
DriverManager.getConnection("jdbc:virtuoso://localhost:1111","dba","dba");
// Query database ...
ExecuteQuery (conn, "sparql select * where {?s ?p ?o} limit 10");
}
}
$ /usr/bin/javac -classpath "../../libsrc/JDBCDriverType4/virtjdbc3.jar:."
sample.java
$ /usr/bin/java -classpath "../../libsrc/JDBCDriverType4/virtjdbc3.jar:." sample
EXECUTE: sparql select * where {?s ?p ?o} limit 10
s p o
--------------
http://www.openlinksw.com/virtrdf-data-formats#default-iid
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nullable
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nonblank
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nonblank-nullable
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#default
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#default-nullable
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#sql-varchar
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#sql-varchar-nullable
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#sql-varchar-dt
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
http://www.openlinksw.com/virtrdf-data-formats#sql-varchar-dt-nullable
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat
Also not section 7.4.3.5 of the Virtuoso JDBC documentation detailing the JDBC
extension for differentiating between RDF triple object literals and IRIs:
http://docs.openlinksw.com/virtuoso/VirtuosoDriverJDBC.html#jdbc3features
Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support
Twitter: http://twitter.com/OpenLink
On 21 Mar 2010, at 08:01, Madhuvanthi Sankaranarayanan wrote:
> Hi,
>
> I have stored a triples file(http://sider.com) in virtuoso quad store.I am
> trying to access it using jdbc.Part of my program is something like this
>
> Class.forName("virtuoso.jdbc3.Driver");
> String url = "jdbc:virtuoso://localhost:1111/DATABASE=DB/UID=dba/PWD=dba/";
> Connection conn = DriverManager.getConnection(url, "dba", "dba");
> Statement stmt = conn.createStatement();
> String graph = "<http://www.sider1.com>";
> boolean more = stmt.execute( "sparql SELECT ?s ?r ?o FROM " + graph + " WHERE
> { ?s ?r ?o } LIMIT 10");
>
>
> Am trying to follow the instructions in the following link
> http://wikis.openlinksw.com/dataspace/owiki/wiki/VirtuosoWikiWeb/WinJDBCtoVirt.
> Every time i try to open the JDBCDemo bat file by double clicking on it,it
> does not open.Any idea why that is happening.or is there any other way to
> connect to virtuoso quad store.
> any examples or documentation?
>
> Thanks,
> Madhu.
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev_______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users