This HTML5 document contains 30 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
dctermshttp://purl.org/dc/terms/
atomhttp://atomowl.org/ontologies/atomrdf#
n17http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/VirtTipsAndTricksGuideMultithreadJDBC/sioc.
foafhttp://xmlns.com/foaf/0.1/
n8http://vos.openlinksw.com/dataspace/services/wiki/
oplhttp://www.openlinksw.com/schema/attribution#
n2http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
dchttp://purl.org/dc/elements/1.1/
n4http://vos.openlinksw.com/dataspace/dav#
rdfshttp://www.w3.org/2000/01/rdf-schema#
n9http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n15http://vos.openlinksw.com/dataspace/person/dav#
n10http://docs.openlinksw.com/virtuoso/VirtuosoDriverJDBC.
n12http://vos.openlinksw.com/dataspace/owiki/wiki/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n6http://vos.openlinksw.com/dataspace/owiki#
xsdhhttp://www.w3.org/2001/XMLSchema#
n14http://vos.openlinksw.com/dataspace/person/owiki#
siochttp://rdfs.org/sioc/ns#
Subject Item
n15:this
foaf:made
n2:VirtTipsAndTricksGuideMultithreadJDBC
Subject Item
n4:this
sioc:creator_of
n2:VirtTipsAndTricksGuideMultithreadJDBC
Subject Item
n8:item
n9:services_of
n2:VirtTipsAndTricksGuideMultithreadJDBC
Subject Item
n6:this
sioc:creator_of
n2:VirtTipsAndTricksGuideMultithreadJDBC
Subject Item
n12:VOS
sioc:container_of
n2:VirtTipsAndTricksGuideMultithreadJDBC
atom:entry
n2:VirtTipsAndTricksGuideMultithreadJDBC
atom:contains
n2:VirtTipsAndTricksGuideMultithreadJDBC
Subject Item
n2:VirtTipsAndTricksGuideMultithreadJDBC
rdf:type
atom:Entry sioct:Comment
dcterms:created
2017-06-13T05:43:04.327391
dcterms:modified
2017-06-29T07:41:35.746757
rdfs:label
VirtTipsAndTricksGuideMultithreadJDBC
foaf:maker
n14:this n15:this
dc:title
VirtTipsAndTricksGuideMultithreadJDBC
opl:isDescribedUsing
n17:rdf
sioc:has_creator
n4:this n6:this
sioc:content
%META:TOPICPARENT{name="VirtTipsAndTricksGuide"}% ---+How can I make Multi Thread Virtuoso connection using JDBC? This sample demonstrates simple java code for performing Multi Thread Virtuoso connection using JDBC. It starts 3 threads: one thread executes SPARQL select and two threads execute SPARQL inserts: <verbatim> import java.util.*; import java.sql.*; import java.math.*; public class MTtest extends Thread { int mode = 0; int startId = 0; static String urlDB = "jdbc:virtuoso://localhost:1111"; public MTtest(int _mode, int _init) { mode = _mode; startId = _init; } void prnRs(ResultSet rs) { try { ResultSetMetaData rsmd; System.out.println(">>>>>>>>"); rsmd = rs.getMetaData(); int cnt = rsmd.getColumnCount(); while(rs.next()) { Object o; System.out.print("Thread:"+Thread.currentThread().getId()+" "); for (int i = 1; i <= cnt; i++) { o = rs.getObject(i); if (rs.wasNull()) System.out.print("<NULL> "); else System.out.print("["+ o + "] "); } System.out.println(); } } catch (Exception e) { System.out.println(e); e.printStackTrace(); } System.out.println(">>>>>>>>"); } public static void main(String argv[]) { try { Class.forName("virtuoso.jdbc3.Driver"); Connection conn = DriverManager.getConnection(urlDB,"dba","dba"); Statement st = conn.createStatement(); st.execute("sparql clear graph <mttest>"); st.execute("sparql insert into graph <mttest> { <xxx> <P01> \"test1\" }"); st.execute("sparql insert into graph <mttest> { <xxx> <P01> \"test2\" }"); st.execute("sparql insert into graph <mttest> { <xxx> <P01> \"test3\" }"); st.execute("sparql insert into graph <mttest> { <xxx> <P01> \"test4\" }"); st.execute("sparql insert into graph <mttest> { <xxx> <P01> \"test5\" }"); conn.close(); int init = 0; for(int i=0; i < 2; i++) { MTtest thr1 = new MTtest(1, init); init+=10; MTtest thr2 = new MTtest(0, init); init+=10; MTtest thr3 = new MTtest(0, init); init+=10; thr1.start(); thr2.start(); thr3.start(); thr1.join(); thr2.join(); thr3.join(); } System.out.println("===End==="); } catch (Exception e) { System.out.print(e); e.printStackTrace(); } } public void run( ) { try { Connection conn = DriverManager.getConnection(urlDB,"dba","dba"); Statement st; st = conn.createStatement(); if (mode == 1) { String query = "sparql SELECT * from <mttest> WHERE {?s ?p ?o}"; ResultSet rs = st.executeQuery(query); prnRs(rs); } else { long id = Thread.currentThread().getId(); for (int i =0; i < 5; i++) st.execute("sparql insert into graph <mttest> { <xxx"+startId+"> <P"+id+"> \"test"+i+"\" }"); System.out.println("\nThread:"+Thread.currentThread().getId()+" ===Rows Inserted==="); } conn.close(); } catch (SQLException e) { System.out.println("==========================================================="); System.out.println(">>["+e.getMessage()+"]"); System.out.println(">>["+e.getErrorCode()+"]"); System.out.println(">>["+e.getSQLState()+"]"); System.out.println(e); System.out.println("==========================================================="); e.printStackTrace(); System.exit(-1); } catch (Exception e) { System.out.println("==========================================================="); System.out.println(e); System.out.println("==========================================================="); e.printStackTrace(); System.exit(-1); } } // run( ) } </verbatim> ---+++Related * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] * [[http://docs.openlinksw.com/virtuoso/VirtuosoDriverJDBC.html][Virtuoso Driver for JDBC]]
sioc:id
645ccf6272306403756d0fd896bc91a1
sioc:link
n2:VirtTipsAndTricksGuideMultithreadJDBC
sioc:has_container
n12:VOS
n9:has_services
n8:item
atom:title
VirtTipsAndTricksGuideMultithreadJDBC
sioc:links_to
n10:html
atom:source
n12:VOS
atom:author
n15:this
atom:published
2017-06-13T05:43:04Z
atom:updated
2017-06-29T07:41:35Z
sioc:topic
n12:VOS