DB2 v.10.1 RDF data deletion - db2

Have anybody tried to remove data(triples) from the DB2 RDF simple store(Windows)? (INSERT works fine)
SPARQL DELETE statament:
DELETE { ?document ?property ?value} WHERE{ ?document <http://example.com#begin>
?begin .
FILTER(?begin > 200) ?document ?property ?value }
I've got the following exception:
com.ibm.rdf.store.exception.RdfStoreException: DB255006E ERRORCODE=-4499, SQLSTATE=08001. SQLSTATE: 08001.
at
com.ibm.rdf.store.internal.jena.impl.update.SingleTripleOperations.removeQuad(Unknown Source)
at com.ibm.rdf.store.internal.jena.impl.update.AbstractTripleOperation.removeQuad(Unknown Source)
.....
db2diag.log:
RETCODE : ZRC=0x87120007=-2028863481=SQLR_SEVERE_PGM_ERROR
"Severe programming error"
DIA8516C A severe internal processing error has occurred.
My Java code:
String queryString = "delete ...";
Dataset ds = RdfStoreFactory.connectDataset(storeP, conn);
GraphStore graphStore = GraphStoreFactory.create(ds) ;
UpdateAction.parseExecute(queryString, graphStore); // exception
//UpdateAction.parseExecute("DROP ALL", graphStore); // works fine
Thanks!

The problem solved by adding
prop.setProperty("enableExtendedIndicators", "2");
to the DB2 connection.

Related

KSQL Java Client app Received 404 response from server:

I have written KSQL Client Java app to fetch the topic message details from KSQL Tables. This is the code snippet to read the topic messages from KSQL table. But when i run this program getting below error. Please let me know how to resolve this issue.
KSQLClient Code:
ClientOptions options = ClientOptions.create()
.setHost(KSQLDB_SERVER_HOST)
.setPort(KSQLDB_SERVER_HOST_PORT);
Client client = Client.create(options);
System.out.println("Client object value ---->"+client);
// Send requests with the client by following the other examples
String query = "SELECT * FROM TESTKSQLTBLE EMIT CHANGES;";
Map<String, Object> properties = Collections.singletonMap("auto.offset.reset", "earliest");
client.streamQuery(query, properties)
.thenAccept(streamedQueryResult -> {
System.out.println("Result column names: " + streamedQueryResult.columnNames());
// RowSubscriber subscriber = new RowSubscriber();
//streamedQueryResult.subscribe(subscriber);
}).exceptionally(e -> {
System.out.println("Push query request failed: " + e);
return null;
});
Exception details:
Exception in thread "main" java.util.concurrent.ExecutionException: io.confluent.ksql.api.client.exception.KsqlClientException: Received 404 response from server: HTTP 404 Not Found. Error code: 40400
at java.util.concurrent.CompletableFuture.reportGet(Unknown Source)
at java.util.concurrent.CompletableFuture.geta(Unknown Source)
at my.ksqldb.app.KSQLExampleApp.main(KSQLExampleApp.java:55)

Error when trying to insert input from user into SQL table

I'm having a problem, whenever I try to run the code below and select the statement 2 to insert a tool and put a random tool name I get the error message : ProgrammingError('column "inserttool' does not exist\nLine 1: insert tools(tool_name, rental_days) values(#insertTool, '2') .
Here is the code :
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(#InsertTool, '2')"""
try:
cursor.execute( insert_tool);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close();
try this.
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(%s, %s)"""
val = (InsertTool, "2")
try:
cursor.execute(insert_tool, val);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close();

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

While executing insert and update command in oracle 11g I'm getting below error.
val stmt = con.createStatement()
//Insert
val query1 = "insert into audit values('D','abc','T','01-NOV-18','Inprogress')"
stmt.executeUpdate(query1)
//Update
val query2 = "Update audit Set status='test' where where product= = 'D'"
stmt.executeUpdate(query2)
I'm getting below error
//Error while updating record
Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1036)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1845)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1810)
at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:294)
at com.oracle.OracleConnection$.main(OracleConnection.scala:21)
at com.oracle.OracleConnection.main(OracleConnection.scala)
Process finished with exit code 1
Any help will be appreciated. Thanks in advance
You have two where and two = in your update query.
val query2 = "Update audit Set status='test' where product='D'"

Retrieving of PostgreSQL native error code

I have installed unixODBC-2.3.1-4.95.x86_64 on my SLES 12 machine and writing some application. But I faced with problem of error handling in PosgreSQL using unixODBC.
To do this I created the following function:
void checkDiag (SQLSMALLINT handleType, SQLHANDLE handle)
{
SQLRETURN rc = SQL_ERROR;
SQLCHAR sqlState[6];
SQLINTEGER nError;
SQLSMALLINT recnum = 0;
SQLCHAR eMsg[SQL_MAX_MESSAGE_LENGTH];
SQLCHAR nativeError[SQL_MAX_MESSAGE_LENGTH];
while (rc != SQL_NO_DATA_FOUND)
{
rc = SQLGetDiagRec (handleType,
handle,
recnum,
sqlState,
&nError,
eMsg,
255,
NULL);
if (rc != SQL_NO_DATA_FOUND)
{
SQLGetDiagField(handleType,
handle,
recnum,
SQL_DIAG_NATIVE,
nativeError,
255,
NULL);
printf("RECNUM %d\n sqlState = %s\n nError = %d\n Error Message %s\n nativeError %s \n",
recnum, sqlState, nError, (char *) eMsg, (char *)nativeError);
}
recnum++;
}
}
I have been trying to use different variants of diagId in SQLGetDiagField : SQL_DIAG_MESSAGE_TEXT, SQL_DIAG_NATIVE, SQL_DIAG_SQLSTATE.
I got everything but not PostgreSQL error Id.
I am constantly getting Postgresql error code id = -1.
So my question is:
Is it possible to get native PostgreSQL error code id using unixODBC API ?
Could you please tell me what I am doing wrong?
I found a solution.
The contents of the config file odbcinst.ini was the following:
[PostgreSQL]
Description=PostgreSQL ODBC driver
Driver=/usr/lib64/unixODBC/libodbcpsql.so
FileUsage=1
After I changed the description of Driver entry in the configuration file I was able to get PostgreSQL native error code.
[PostgreSQL]
Description=PostgreSQL ODBC driver
Driver=/opt/PostgreSQL/psqlODBC/lib/psqlodbcw.so
FileUsage=1
psqlodbcw.so library is supplied by EnterpriseDB PostgreSQL which can be downloaded here https://www.postgresql.org/download/linux/suse/ .
After these modifications I can get native error code. Using the code provided above, the postgres error code value will be written into sqlState.

org.postgresql.util.PSQLException: No results returned by the query

hey everyone am trying to insert data in a table using #Query annotation in my spring boot app am getting a postgres Exception :
org.postgresql.util.PSQLException: No results returned by the query
this is my code :
this is the repository
#Query(value="INSERT INTO \"FCT_BY_DEV\"(\"IdDev\", \"IdFonction\") VALUES (?, ?) ",nativeQuery=true)
public String isertfonctionstodev(int dev,int fonction);
this is the controller :
#RequestMapping(value="/function/insert", method = RequestMethod.POST)
public String insererfonctions (int dev,int fonction){
System.out.println("dev="+dev+"fonction="+fonction);
fonctionRepository.isertfonctionstodev(dev, fonction);
System.out.println("********");
return "aaa";
}
am using this service by $http in angularJs
$http.post("/function/insert?dev="+$scope.id+"&fonction="+$scope.idf);
and finaly this is the server log
dev=16006fonction=14
Hibernate: INSERT INTO "FCT_BY_DEV"("IdDev", "IdFonction") VALUES (?, ?)
2016-04-27 16:52:03.204 WARN 7036 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 02000
2016-04-27 16:52:03.204 ERROR 7036 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : Aucun résultat retourné par la requête.
the data is correct and i tried the same query with the same value and it worked why posgres is generating this exception and how can i fixed , thanks to any help
I think modifying queries must be annotared with an extra
#Modifying
This should solve your issue:
#Transactional
#Modifying(clearAutomatically = true)
#Query(value="update policy.tbl_policy set ac_status = 'INACTIVE' where pol_id = :policyId and version_no = :version_no and ac_status = 'ACTIVE'", nativeQuery=true)
public void updateExistingRowbyId(#Param("policyId") Long pol_id, #Param("version_no") Long version_no);
Without #Transactional annotation, following errors may occur:
javax.persistence.TransactionRequiredException: Executing an update/delete query