-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Added Property JDBC statement
PostPosted: Wed Jul 16, 2008 10:00 am 
Newbie

Joined: Thu Mar 27, 2008 9:28 am
Posts: 9
Hi,

I want to add a property JDBC of my database. Without hibernate, I write:

Code:
stmt.executeUpdate("PRAGMA synchronous = OFF;");


stmt for statement.

But When I use Hibernate I have an exception:

Code:
java.sql.SQLException: Safety level may not be changed inside a transaction
   at org.sqlite.DB.throwex(DB.java:252)
   at org.sqlite.NativeDB.prepare(Native Method)
   at org.sqlite.DB.prepare(DB.java:62)
   at org.sqlite.Stmt.executeUpdate(Stmt.java:82)
   at com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate(NewProxyStatement.java:64)


Is it possible to set the property at Hibernate with an other solution.

Thanks


Top
 Profile  
 
 Post subject: Re: Added Property JDBC statement
PostPosted: Wed Jul 16, 2008 11:27 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Is it something you want to do for all use cases or just a few? Some connection pools allow you to specify a sql statement that will be executed each time a connection is checked out. You could use that if this setting applies to all use cases.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 1:04 am 
Newbie

Joined: Thu Mar 27, 2008 9:28 am
Posts: 9
I want to do for all use cases, but How could I to do ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 2:23 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
JeromeG wrote:
I want to do for all use cases, but How could I to do ?


What is your connection pool/datasource?


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 1:08 am 
Newbie

Joined: Thu Mar 27, 2008 9:28 am
Posts: 9
I use C3PO and SQLite.

To improve the perforamces, we can to give a statement at SQLite:

Code:
stmt.executeUpdate("PRAGMA synchronous = OFF;");


But I don't happen to give it in parameter at SQLite.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 10:26 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Not exactly what I had in mind but set this to true:

Code:
testConnectionOnCheckout
    Default: false
    Use only if necessary. Expensive. If true, an operation will be performed at every connection checkout to verify that the connection is valid. Better choice: verify connections periodically using idleConnectionTestPeriod. Also, setting an automaticTestTable or preferredTestQuery will usually speed up all connection tests. [See "Configuring Connection Testing"]


and set this to your sql:

Code:
preferredTestQuery
    Default: null
    Defines the query that will be executed for all connection tests, if the default ConnectionTester (or some other implementation of QueryConnectionTester, or better yet FullQueryConnectionTester) is being used. Defining a preferredTestQuery that will execute quickly in your database may dramatically speed up Connection tests. (If no preferredTestQuery is set, the default ConnectionTester executes a getTables() call on the Connection's DatabaseMetaData. Depending on your database, this may execute more slowly than a "normal" database query.) NOTE: The table against which your preferredTestQuery will be run must exist in the database schema prior to your initialization of your DataSource. If your application defines its own schema, try automaticTestTable instead. [See "Configuring Connection Testing"]
.

These have been copied from c3p0's documentation.


Farzad-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.