JdbcTemplate 1 « Database « Spring Q&A





1. Spring JdbcTemplate and Threading    stackoverflow.com

Is it safe to fork off a Thread to execute an insert using a JdbcTemplate in Swing. It's a logging event and as much as possible I don't want it to affect ...

2. Building a data layer using Spring JdbcTemplate    stackoverflow.com

Do you know of any resources that describe building a data access layer using Spring's JdbcTemplate classes? I'm looking for something beyond the basics described in the Spring framework documentation. ...

3. How can I cancel a long-running query using Spring and JDBCTemplate?    stackoverflow.com

The JDBC java.sql.Statement class has a cancel() method. This can be called in another thread to cancel a currently running statement. How can I achieve this using Spring? I can't find a ...

4. How to execute IN() SQL queries with Spring's JDBCTemplate effectivly?    stackoverflow.com

i was wondering if there is a more elegant way to do IN() queries with Spring's JDBCTemplate. Currently i do something like that:

StringBuilder jobTypeInClauseBuilder = new StringBuilder();
for(int i = 0; i ...

5. Spring RDBMS vs JDBCTemplate    stackoverflow.com

How much of a performance difference is there between these two models? What kind of reasons are there for using one over the other? In my application I am using a ...

6. identity from sql insert via jdbctemplate    stackoverflow.com

Is it possible to get the @@identity from the SQL insert on a Spring jdbc template call? If so, how?

7. Spring JdbcTemplate returns empty result when there should be a valid result    stackoverflow.com

I'm using SimpleJdbcDaoSupport object to access DB resources. I have a query which is frequently executed against the database to locate a record with a specific key. for some reason after ...

8. Seeing the underlying SQL in the Spring JdbcTemplate?    stackoverflow.com

I am learning about the wonders of JdbcTemplate and NamedParameterJdbcTemplate. I like what I see, but is there any easy way to see the underlying SQL that it ends up executing? ...

9. How to generate a dynamic "in (...)" sql list through Spring JdbcTemplate?    stackoverflow.com

Is it possible to generate arbitrary "in ()" lists in a SQL query through Jdbc template: example: "select * from t where c in (#)" , However '#' could be an arbitrary list ...





10. using Spring JdbcTemplate    stackoverflow.com

if i create a new instance of JdbcTemplate like so; JdbcTemplate jdbcTemplate = new JdbcTemplate(getDataSource()); by passing the datasource as a param (the datasource retrieves a connection from server connection pool) am i ...

11. Problem with updating using Spring's JdbcTemplate    stackoverflow.com

I've a function updating database table using Spring's JdbcTemplate and for some reason there was exceptin that connection is read only u can not update any database related changes. How to ...

12. using Spring JdbcTemplate for multiple database operations    stackoverflow.com

I like the apparent simplicity of JdbcTemplate but am a little confused as to how it works. It appears that each operation (query() or update()) fetches a connection from a datasource ...

13. Open JdbcTemplate connection in read only mode (Spring framework)?    stackoverflow.com

is it possible to open a JdbcTemplate connection in read only mode, so that I can't perform any changes to the underlying data source?

14. How to make a thread try to reconnect to the Database x times using JDBCTemplate    stackoverflow.com

I have a single thread trying to connect to a database using JDBCTemplate as follows:

JDBCTemplate jdbcTemplate =  new JdbcTemplate(dataSource); 

try{
    jdbcTemplate.execute(new CallableStatementCreator() {
     ...

15. JdbcTemplate — logging the dataSource connection url    stackoverflow.com

is there a way to log the JdbcTemplate's DataSource connection URL in Java? The field exists in the DataSource, but there ain't a getter to access it. Of course I could read ...

16. Dynamically select field names in a query with Spring JDBCTemplate    stackoverflow.com

I have a problem with parameters replacing by Spring JdbcTemplate. I have this query :

    <bean id="fixQuery" class="java.lang.String">
    <constructor-arg type="java.lang.String"
       ...





17. using JdcbTemplate standalone    stackoverflow.com

We are looking into using the JdbcTemplate for accessing the DB - but we have many different DB-connections, that each class could use, so injecting the jdbcTemplate is not an option ...

18. Instantiating a JdbcTemplate from a java.sql.Connection    stackoverflow.com

I want to obtain a JdbcTemplate in my Java code. I've already got a working java.sql.Connection. To create a new JdbcTemplate it would normally need an instance ...

19. Spring JDBC vs JDBC    stackoverflow.com

I have been trying to use spring 3.0 SimpleJdbcTemplate and it takes 5 mins to insert 1500 records, whereas it take me a few secs. to insert using straight JDBC. Not ...

20. Can I ask JDBCTemplate to expand a list parameter for use in an in() clause?    stackoverflow.com

Can I do something like this:

select * from mytable m where m.group_id in (?)
... and pass in a list or array of arguments to be expanded in to my parameter, ie:
select ...

21. Hard time with Spring anonymous/callback classes for data persistence    stackoverflow.com

I'm trying to accommodate to Spring JDBC, but what bugs me is using these anonymous classes, where we cannot pass any local variables unless they are final which might be easy ...

22. Where to keep large SQL queries when usuing Spring's JdbcTemplate classes    stackoverflow.com

I'm developing a DAO using Spring JdbcDaoSupport and would like to know if anyone can suggest best practice for externalizing the SQL from the Java code. I'm used to using Hibernate and ...

23. Spring JdbcTemplate ConnectionPooling Configuration    stackoverflow.com

I am working on a Spring MVC application in which I have recently been convinced to revamp my database code. Before I was using very traditional JDBC code that I have ...

24. Paged queries with JdbcTemplate    stackoverflow.com

I'm currently working on a migration project, to migrate data from the old db to the new one (please do not ask why I'm going through a Java application for this, ...

25. Spring JDBCTemplate Vs Plain JDBC for insert    stackoverflow.com

We have to insert 2 millions of records across multiple tables and right now we are writing into csv file and using db2 import to load into database. We wanted to change ...

26. Spring JDBCTemplate on Seam-based app    stackoverflow.com

When manual SQL is required (JDBC API with pre-written queries), what is the best approach in a Seam-based application ? In Seam Documentation, use of Spring bridge to inject a ...

27. Problem autowiring JDBCTemplate in Spring component    stackoverflow.com

I have command line application, the application start a bean, like this

ApplicationContext context =
    new ClassPathXmlApplicationContext(new String[] {"some-spring-config.xml"});
SomeClass c = context.getBean(SomeClass.class)
Anyway, the clas do autowired for some more ...

28. Spring JdbcTemplate - How to restrict queries to SELECT(s)?    stackoverflow.com

I am writing a program that uses JdbcTemplate and executes a user query. Is there a way through the Spring JDBC package that I can restrict user queries to SELECT statements? ...

29. Help need with transforming Java lists/collections or something    stackoverflow.com

I have a list of objects returned from getJdbcTemplate().query that look like this

object(test,test,test,1)
object(test,test,test,2)
object(test,test,test,3)
How can I transpose these into one object that looks like this
object(test,test,test,list<t>({1,2,3}))
Hopefuly you get the idea from my ...

30. How to reuse the same connection with a Spring's JdbcTemplate?    stackoverflow.com

I have the following code:


    @Test
    public void springTest() throws SQLException{
        //Connect to the DB.
    ...

31. how to execute insert statement using jdbcTemplate in springs    stackoverflow.com

In Spring, how can I insert data in table using jdbcTemplate. Can anyone please provide me a code sample for doing this.

32. DB precision padded with random numbers using Spring JdbcTemplate    stackoverflow.com

I use Spring's JdbcTemplate to run an insert SQL statement. The field I want to insert into is a NUMBER. The value is: -0.11111111 of type float. However, after insertion into ...

33. Does Spring's JdbcTemplate close the connection if an exception is thrown?    stackoverflow.com

When Spring catches an SQLException, does it close the prepared statement, result set, and/or connection before throwing it's own DataAccessException (runtime) exception? I have a developer who wants to create an AOP ...

34. Can I set a JDBC timeout for a single query?    stackoverflow.com

I have a web app on Tomcat, which handles DB connection pooling, and using Spring JDBCTemplate for executing queries. It's been requested that I implement a status page which will ...

35. Unit testing a DAO class that uses Spring JDBC    stackoverflow.com

I have several DAO objects that are used to retrieve information from a database and I really want to write some automated tests for them but I'm having a hard time ...

36. Question on Spring JDBCTemplate and Create BO data graph in DAO Layer or Business Layer?    stackoverflow.com

I am working on a small project, on DAO layer I am using Spring JDBCTemplate. Having all DAO and Service configured in Spring configure file. My question is

  1. One DAO should concentrate on read/ave one ...

37. Populating pojo from a db using spring jdbctemplate    stackoverflow.com

Is it possible to populate an object (pojo) without creating a mapper, by allowing spring to auto detect the names of the data members that matches the columns? I was expecting to ...

38. How to get a DBUnit DatabaseConnection instance from Spring JdbcTemplate instance    stackoverflow.com

I'm trying to use a Spring JdbcTemplate instance to generate a DataSet useable for subsequent DBUnit tests. any ideas how to do that? all the documentation I found where going from a JDBC ...

39. Is there a Eclipse plugin for Spring JDBCTemplate code generation?    stackoverflow.com

I am planing to use Spring JDBCTemplate for all my database needs. I wanted to know if there is a Eclipse plugin which will take a data base table and auto ...

40. Spring jdbcTemplate dynamic where clause    stackoverflow.com

Is it possible to generate arbitrary where condtions SQL query through Jdbc template: example: If i pass value for 1 parameter (only name) : search by name

"select * from address where shopname = ...

41. addBatch support in Spring JDBCTemplate?    stackoverflow.com

I want to execute multiple, separate SQL statements like in the JDBC cookbook:

Statement stmt = con.createStatement();
stmt.addBatch(
    "update registration set balance=balance-5.00
    where theuser="+theuser);
stmt.addBatch(
"insert into auctionitems(
  ...

42. Spring: Does JdbcTemplate.query() with a RowCallbackHandler make concurrent calls to processRow()?    stackoverflow.com

The Spring docs specify the RowCallbackHandler argument as an "object that will extract results, one row at a time". I see that processRow() is called once per row, but ...

43. using spring jdbc template for populating results    stackoverflow.com

I have two classes

class Deptartment{
  int deptid,
  String deptname;
  List<Employee> employees;

}

class Employee{

 int empid;
 String empname;
 int deptid;

}

Table: 
Department:

    deptid,deptname

Employee

    empid,empname,deptid

Query: select ...

44. How do I get data from Tapestry BeanEditForms?    stackoverflow.com

I'm using Tapestry 5 and I have a page on which I have a bean edit form. How do I get data submitted in that form after click on submit? ...

45. Creating SQL statements programmatically using Spring    stackoverflow.com

I need to create SQL statement programmatically. I have values in map in form <"column_name",value>. Now I have a base query, I add a where clause and as iterating through the ...

46. Application hangs up randomly in jdbcTemplate for update    stackoverflow.com

I am using simpleJdbcTemplate of Spring to execute update with query shown below:

update TABLE B JOIN 
(select Column1 from TABLE A
) C ON B.Column2 = C.Column3
set B.Column4 = 1
Transaction timeout is ...

47. how to pass multiple values to query using jdbcTemplate in spring    stackoverflow.com

In my Spring Hibernate application i have all the sql queries in one common_queries.xml file,where some queries require 2 to 3 parameters shown as below

   <query id="mining.fuel" no-of-params="2">
select ms.id ...

48. How do I assign variables with values from a list?    stackoverflow.com

I am running this code:

int key = 25;
String query = "Select one, two, three, four, five from myTable where key=?";
List<Map<String,Object>> data = jdbcTemplate.queryForList(query, new Object[]{key});

//one is string, two is int, three ...

49. How can I use JDBCTemplate from Spring JDBC in a Swing desktop application?    stackoverflow.com

I use a lot of JDBC code in my Swing desktop application. Now I read about JDBCTemplate from Spring in Spring in Action and it looks like a nice API for ...

50. spring jdbctemplate: different behaviour on different app servers (date issue)    stackoverflow.com

I am running the same select query on the same database using the same code but using 2 different app servers. Query: Find a certian day's entries in a journal. 1) Existing legacy ...

51. Spring - jdbcTemplate    stackoverflow.com

I'm just beginning with Spring framework. I'm also using DBCP pooling and i'm still not sure how to work right with jdbcTemplate. It is best practice to reuse created/injected jdbcTemplate instance between ...

52. issue mocking spring jdbctemplate with @Autowired    stackoverflow.com

I use mockito as a mock object library. I am unit testing DAOs. DAOs expect JdbcTemplate to be injected through @Autowired. Hence, there are no setter methods for JDBC Template in DAOs ...

53. NulllPointerException when accessing database with JdbcTemplate in Spring    stackoverflow.com

I'm a Spring newbie, I'm following some examples from books and tutorials in the spring website and I can't get my code to work. I'm trying to access to a DataBase ...

54. When using jdbctemplate with spring, should I have a base class?    stackoverflow.com

I'm moving from hibernate to jdbctemplate in spring, and need some guidance. I'm going to create a UserDao and then a UserDaoImpl. In my servlet.xml file I have my datasource bean created. Now I'm ...

55. Possible to avoid code changes during schema changes when using Jdbctemplate?    stackoverflow.com

When using spring's JdbcTemplate, I am using the row mapper to map results coming back. The benefit with this is that there are less places where I have to change my code ...

56. How to select schema with JdbcTemplate?    forum.springsource.org

How to select schema with JdbcTemplate? Hi I have created an EmployeeDAO to read from employee table from postgreSQL. This table is in schema abc. This table can be present in ...

57. Selecting schema with JdbcTemplate    forum.springsource.org

Selecting schema with JdbcTemplate Hi I am using PostgreSQL and i need to select schema dynamically for each query based on the user. Foe example, if user is abc, I have ...

58. MockObjects or DBUnit for testing Code using JdbcTemplate    forum.springsource.org

MockObjects or DBUnit for testing Code using JdbcTemplate Hi, I'm looking at a way to test the following code against a mock object, or test database using DBUnit: Code: public List ...

59. Possible Bug With JdbcTemplate getObject    forum.springsource.org

Possible Bug With JdbcTemplate getObject Hello, The javadocs say that getObject(String, Object[], Class) will return NULL if the result of the query is NULL. I am testing for a NULL in ...

60. JDBCTemplate to call Oracle Function in Spring    forum.springsource.org

JDBCTemplate to call Oracle Function in Spring I have spent three days on this issue and still no success. Please help! I have an oracle stored function that selects all records ...

61. Leveraging jdbcTemplate for SQL checks without AbstractJpaTests    forum.springsource.org

In spring 2.x we had AbstractJpaTests , which gave us access to jdbcTemplate which we could use to check state in database. Since in Spring 3 AbstractJpaTests is deprecated, what is ...

62. DB precision padded with random numbers using Spring JdbcTemplate    forum.springsource.org

I use Spring's JdbcTemplate to run an insert SQL statement. The field I want to insert into is a NUMBER. The value is: -0.11111111. However, after insertion into DB, the value ...

63. jdbcTemplate maximum no. of statements    forum.springsource.org

Hi, what is the maximum number of SQL statements that I can successfully execute in a Spring jdbcTemplate batchUpdate function. Code: List sqlParamValList = new ArrayList(); jdbcTemplate.batchUpdate("update oracle_db_table set column_1=?, column_2=? ...

64. JdbcTemplate inside EJBs/ connection management    forum.springsource.org

JdbcTemplate inside EJBs/ connection management Hello, I'm using JdbcTemplate in an ejb 3.0 application, but I'm using it as a share library. So I'm doing something like: InitialContext initialContext = new ...

65. DDL with parameters in JdbcTemplate    forum.springsource.org

Hi, I can't figure out how to execute DDL with parameters using some of the JdbcTemplate family classes. Specifically I am trying to create a user in oracle database and neither ...

66. jdbctemplate on websphere running out of connection..    forum.springsource.org

jdbctemplate on websphere running out of connection.. Hi, I have an EJB (MDB) in which I am using jdbctemplate to do some DB operations. After a while I start getting connection ...

67. Performance Issues - JdbcTemplate    forum.springsource.org

Performance Issues - JdbcTemplate Hi, I am having a performance issue when load testing a simple application that reads from a database. My initial thoughts that this is due to the ...

68. JdbcTemplate.queryForObject question    forum.springsource.org

JdbcTemplate.queryForObject question This is a simple question, but the answer is not clear from the docs. Let's say I use the following: JdbcTemplate jt=new JdbcTemplate(dataSource); String s= (String) jt.queryForObject("select name from ...

69. JdbcTemplate - Intercepting "getConnection()" method    forum.springsource.org

You don't give enough information about your configuration. Are you using full-blown AspectJ or Spring AOP with aspectj:autoproxy? If you're using Spring AOP, you made 2 evident mistakes: - first, a ...

70. My first using of JdbcTemplate in process is slow (connection problem)    forum.springsource.org

My first using of JdbcTemplate in process is slow (connection problem) Hi, I'm developing a batch with Spring Batch. In a step, i have some processors that use JdbcTemplate to execute ...

71. can jdbcTemplate use java.util.Date    forum.springsource.org

can jdbcTemplate use java.util.Date I have a query similar to String q = "select x.a,y.b from x, y where x.ref_id=y.id and ? between y.startDate and y.endDate"; jdbcTemplate.query(q,myDate); if myDate is java.util.Date, ...

72. Error while instantiating JdbcTemplate in spring-config.xml?    forum.springsource.org

Aug 26th, 2011, 01:35 AM #1 VishalJoshi View Profile View Forum Posts Private Message Junior Member Join Date Aug 2011 Posts 1 Error while instantiating JdbcTemplate in spring-config.xml? Hi, here is ...

73. default_schema using JDBCTemplate    forum.springsource.org

How can I define a default_schema for my DAO's that extend JdbcDaoSupport versus HibernateDaoSupport? For my Hibernate DAO's the tables will be prefixed with the hibernate.default_schema property definition, although I don't ...

74. Problem with jdbcTemplate    forum.springsource.org

Problem with jdbcTemplate Hi, I'm using the springs JdbcTemplate for persisting data, I get one problem : This is my update statement : jdbcTemplate.update("insert into LOG_SERVICE_ENTRIES (USER_ID) values (?)", new Object[] ...

75. JDBCTemplate update method executes twice    forum.springsource.org

JDBCTemplate update method executes twice Hello All, I am facing an issue with JDBCTemplate's update method. I am executing an insert query using jdbcTemplate.update method. I have specified the TransactionAttribute on ...

76. JdbcTemplate hangs in JUnit test    forum.springsource.org

JdbcTemplate hangs in JUnit test Hi guys, I have a JUnit test in which I test the number of rows of a table, the thing is it looks like the test ...

77. JdbcTemplate - best practices - share or not to share between DAOs    forum.springsource.org

JdbcTemplate - best practices - share or not to share between DAOs Hello, i'm really new in spring world, so, this question can be a little bit dumb. But, I really ...

78. how to catch SQL exception when using JDBCTemplate    forum.springsource.org

how to catch SQL exception when using JDBCTemplate Hello all: First the title was WRONG, it should be "how to fetch the resultset from a store proc in a batch fasion". ...

79. ArrayIndexOutOfBoundsException using JdbcTemplate.query    forum.springsource.org

I'm trying to query a database using JdbcTemplate.query, and I'm getting an ArrayIndexOutOfBoundsException. Here's what my call looks like: Code: private static String SELECT_ALL_CUSTOMERS = "SELECT * FROM CUSTOMER WHERE CUST_ID ...

80. JDBCTemplate and PreparedStatementCreatorFactory    forum.springsource.org

JDBCTemplate and PreparedStatementCreatorFactory I'm getting some odd behavior out of the PreparedStatementCreatorFactory class. Here's a pseduo code example of what I'm using to create the query: final JdbcTemplate template = new ...

81. JdbcTemplate not working with left outer join    forum.springsource.org

JdbcTemplate not working with left outer join hi, I have a left outer join query which gives the result in the oracle-sql-developer. But when i try to get the results for ...

82. JdbcTemplate.queryForObject strange behaviour    forum.springsource.org

JdbcTemplate.queryForObject strange behaviour When I use the JdbcTemplate.queryForObject like the fragment below, it works fine StringBuffer sqlQuery = new StringBuffer("SELECT a.CodeUser"); sqlQuery.append(" FROM Utilisateur a, Autorisation b, Groupe c, Application d ...

83. How to get large rowset using JDBCTemplate?    forum.springsource.org

I was surprised that I couldn't find a way within the Spring JdbcTempate classes to limit the size of a result set. I have a simple utility that displays the first ...

84. JDBCTemplate Question    forum.springsource.org

JDBCTemplate Question Hello, I am wondering if there is something similar to HibernateDaoSupport for JdbcTemplate? If such a support class exists then I could just add a getter/setter method to any ...

85. JdbcTemplate singleton & thread safety    forum.springsource.org

JdbcTemplate singleton & thread safety I was looking to the source code of an application based on Spring and Struts. Since I was the one who choosed Spring, I was pleased ...

86. JDBCTemplate query method for StoredProcs?    forum.springsource.org

JDBCTemplate query method for StoredProcs? I noticed all the query methods on JdbcTemplate take PreparedStatementCreators or Strings (for SQL). Why aren't there any query methods that take a CallableStatementCreator and a ...

87. JdbcTemplate error    forum.springsource.org

JdbcTemplate error I was using hibernate to do a large amount of data upload, but it seemed to resource heavy, so I decided to implement the upload using Spring's JdbcTemplate. When ...

88. Example of using JdbcTemplate to do an insert    forum.springsource.org

I cannot seem to find any examples of doing an insert, there are lots of selects and updates. Has any one got sample code of doing an insert using an SQL ...

89. Any way to force JdbcTemplate to use a specific Connection?    forum.springsource.org

Any way to force JdbcTemplate to use a specific Connection? I started to convert some jdbc code to use JdbcTemplate, but ran into a problem. Each call to jdbcTemplate.update was getting ...

90. CMT, JdbcTemplate and connection pools    forum.springsource.org

CMT, JdbcTemplate and connection pools I am using JdbcTemplate in a very simple fashion, basically to do mass updates within a session bean's method. I have no configuration for any Spring ...

91. Java 1.5 required for a JdbcTemplate method?    forum.springsource.org

Java 1.5 required for a JdbcTemplate method? I'm trying to use the JdbcTemplate queryForRowSet method (Spring 1.2 final), but I'm getting the following error: java.lang.NoClassDefFoundError: javax/sql/rowset/CachedRowSet It appears that javax.sql.rowset.CachedRowSet is ...

92. JDBCTemplate Performance issue    forum.springsource.org

Hi, I am using Spring's JDBCTemplate to interact with database. We are going through performance tuning phase of our project. We are having few queries if we run them directly on ...

93. Problem Sending NULL LOB Value using JDBCTemplate    forum.springsource.org

Problem Sending NULL LOB Value using JDBCTemplate Hi All, I am trying to send a null to an XMLType (CLOB) in an Oracle 10g database. I use the following: rowsUpdated = ...

94. JdbcTemplate.update() not effective unless followed by query    forum.springsource.org

JdbcTemplate.update() not effective unless followed by query I'm using straight JDBC Prepared Stmts w/the JdbcTemplate as shown in Section 10.2 of Reference Manual on a MSAccess DB. I'm using no transactions; ...

95. JdbcTemplate.call question    forum.springsource.org

The Spring Javadoc for JdbcTemplate.call(CallableStatementCreator, List) indicates the second parameter should be a list of SqlParameter objects. But SqlParameter objects contain only type information, not value information. I'm not sure how ...

96. Running SQL scripts through JdbcTemplate    forum.springsource.org

Running SQL scripts through JdbcTemplate Hi, I'm working on a program to incrementally upgrade our application's database schema. Our app already uses Spring, so what I'd really like to do is ...

97. retrieve sequence value from JdbcTemplate    forum.springsource.org

Hi! I have a Dao that uses JdbcTemplate to retrieve value from a sequence. How can do this? Have I to use a RowMapper or is there a specific JdbcTemplate method ...

98. DataSource in JBoss with JdbcTemplate?    forum.springsource.org

You use a JndiObjectFactoryBean object: jdbc/MyDataSource

99. NoClassDefFoundError: JdbcTemplate - Please help!    forum.springsource.org

NoClassDefFoundError: JdbcTemplate - Please help! Well, m a bit new to the world of spring. Start itself is not very encouraging as i get exception while doing the simple things: When ...

100. Oracle SQL Build in functions and JdbcTemplate    forum.springsource.org

Oct 13th, 2005, 07:04 PM #1 thackker View Profile View Forum Posts Private Message Junior Member Join Date Oct 2005 Posts 10 Oracle SQL Build in functions and JdbcTemplate Hi, I ...