This article came about after a user filed an issue on the JDBC list The specific issue is that I’m using SimpleJdbcCall.execute() to call the database and getting back a Jdbc4Array. When I then try to do something like Jdbc4Array.getArray() I get a SQL error that can be tracked down to the Jdbc driver trying to use a connection object which has already been closed by the Spring Framework.
The problem is that once you get the array back more work has to be done to get the values out of it. The following code is an example of how to use transactions with spring and PostgreSQL JDBC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implementation which does the actual work
Note the @Transaction annotation on line 22, this is required to ensure that the connection is not closed after the first call on line 42
without this annotation spring would close the connection and the next line 43 would throw an exception.
The constructor line 27 is required for spring to create the implementation and inject the datasource defined in the context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Continuous Integration is all about being able to push our code-changes to github and instantly find out if our build fails, or to discover if our code-changes fail our prepared tests.
The last few days I have been testing a continuous integration service provided by the good folks at Travis-CI. Best of all, this continous integration service is free for open source projects!
Using Jsch to scp a file to a remote computer I found Jan Pechanec's excellent blog how_the_scp_protocol_works . The one thing I couldn't figure out was how to specify the remote directory.
Originally I tried using D mode dir to specify the directory. That results in an error.
As you can specify the target directory using scp manually there must have been a way. Turns out it is simple.
Line 43 of scp is String command="scp " + (ptimestamp ? "-p" :"") +" -t "+rfile;
All that is required is to specify the target dir in the command as follows: