spring-jdbc

Overriding timeout for database connection in properties file

谁说我不能喝 提交于 2019-12-08 03:41:27
I was wondering if there is a specific way to override database connection timeout in the properties file in my Java web project? I am using Hibernate, Spring, and MySQL DB. I have tried several different property fields and reduced the timeout time to 1 millsecond, yet the connection is still completed with transactions still being processed properly. These are the property fields I have used to no avail... spring.jpa.properties.javax.persistence.query.timeout=1 spring.jdbc.template.query-timeout=1 hibernate.c3p0.timeout=1 Is hibernate overriding this timeout value or am I just setting it

Method not being intercepted by transaction advisor even though “adding transactional method” seen in logs

混江龙づ霸主 提交于 2019-12-07 10:36:17
问题 I have a @Transactional @Controller , but its methods are being invoked by the Spring MVC framework without a transaction. In the exception trace I do not find the transaction advisor intercepting the call: org.hibernate.HibernateException: No Session found for current thread org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106) org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) org.example.businesslogic

What is interface-based proxying?

会有一股神秘感。 提交于 2019-12-07 06:56:36
问题 I was reading this regarding to where to place Transactional(interface vs implementation): The Spring team's recommendation is that you only annotate concrete classes with the @Transactional annotation, as opposed to annotating interfaces. You certainly can place the @Transactional annotation on an interface (or an interface method), but this will only work as you would expect it to if you are using interface-based proxies. The fact that annotations are not inherited means that if you are

APPARENT DEADLOCK c3p0 0.9.5.1 spring

懵懂的女人 提交于 2019-12-07 06:15:21
问题 We are facing APPARENT DEADLOCK while using c3p0 0.9.5.1 ( which is latest version of c3p0). following is the connection pool config we are using. p:driverClass="${app.jdbc.driverClassReplica}" p:jdbcUrl="jdbc:mysql://database,database/dbname" p:acquireIncrement="5" p:idleConnectionTestPeriod="300" p:maxPoolSize="100" p:maxStatements="2000" p:minPoolSize="10" p:maxIdleTime="1800" p:maxConnectionAge="3600" p:maxIdleTimeExcessConnections="20" p:numHelperThreads="15" p:preferredTestQuery="SELECT

insert row and get generated ID

纵然是瞬间 提交于 2019-12-07 04:38:12
问题 I'm trying to use Spring's JdbcTemplate class to insert a row into a MySQL table named transaction and get the generated ID. The relevant code is: public Transaction insertTransaction(final Transaction tran) { // Will hold the ID of the row created by the insert KeyHolder keyHolder = new GeneratedKeyHolder(); getJdbcTemplate().update(new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection

DB2 Connection Authorization Faliure Occured Reason: Security Mechanism not supported in Java

我的梦境 提交于 2019-12-07 03:25:21
问题 I am trying to configure DB2 connection with DB2JDBC Type4 drivers. But I am getting this error. Exception in thread "main" com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException: [jcc][t4][201][11237][3.64.104] Connection authorization failure occurred. Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000 My code is public Connection getConnection() throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException{ Driver driver = (Driver)

Spring NamedParameterJDBCTemplate reuse of Prepared Statements

寵の児 提交于 2019-12-07 00:36:45
问题 I am using the Spring NamedParameterJdbcTemplate to fetch some values from a table. For some reason, the query runs very slow in my Java app as opposed to running the same query on SQL Management Studio. I also noticed in the profiler, the prepared statements don't get reused. If I run the same query in my JAVA app multiple times, I see different prepared statements being executed. So, not sure why the statements are not getting reused. Is the performance slow because I am using a IN clause

Spring Batch JdbcPagingItemReader seems not paginating

回眸只為那壹抹淺笑 提交于 2019-12-06 16:53:11
I'm working on an app that indexes a bunch of files in an embedded Derby(10.12.1.1) DB and then are exported as one single tabulated file. The first part is working fine since the DB is created and all records are indexed. However, when I attempt to read from the DB using JdbcPagingItemReader and write to a file I only get the number of records specified in pageSize . So if the pageSize is 10, then I get a file with 10 lines and the rest of the records seem to be ignored. So far, I haven't been able to find whats is really going on and any help would be most welcome. Here is the

NamedJDBCTemplate Parameters is list of lists

家住魔仙堡 提交于 2019-12-06 16:34:25
I have a query which looks something like this: SELECT * FROM someTable t WHERE (t.a, t.b) IN (VALUES (1, 2), (3, 4)) And it would select any records where t.a == 1 AND t.b == 2 or t.a == 3 AND t.b == 4 . This seems to work just fine. However, I can't figure out a clean way to specify the parameter to NamedJDBCTemplate . I tried giving it a list of lists (i.e., List<List<int>> ), but it seems to blow up doing that. val query = "SELECT * FROM someTable t WHERE (t.a, t.b) IN (VALUES :values)" namedJdbcTemplate.queryForList(query, mapOf("values" to listOf(listOf(1, 2), listOf(3, 4)))) I also

spring ArrayIndexOutOfBoundsException with SimpleJdbcCall

北慕城南 提交于 2019-12-06 15:17:19
This is the Oracle procedure I'm trying to call: PROCEDURE GetCoreReportExtras ( pnAssignment IN NUMBER, pnUserRole in NUMBER, psAreaMenu in VARCHAR2, pnAreaLevel in NUMBER, curReportList OUT outcur, psLDO in VARCHAR2 default 'none', pnAcisNumber in NUMBER default 0); Here's my Java code: private class GetStandardReportExtrasSPV2{ int nAreaLevel; int nAssignment; int nUserRole; int nAcisNum = 0; String strAreaMenu; String strLDO = null; private SimpleJdbcTemplate simpleJdbcTemplate; private SimpleJdbcCall procGetReportExtras; public GetStandardReportExtrasSPV2(DataSource ds, int nUserRole,