I have a Java web-app using standard web.xml and servlets. At the moment, I'm using the <context-param> tags in web.xml to define the database configuration (JDBC url, username, password, etc.). These are picked up by a servlet in its init() method.
But I'd like to not include database username/password in my source repository.
For t...
I have JDBC code which inserts into a database table by executing a PreparedStatement. When I run the code on an in-memory HSQLDB database (as part of a JUnit test) I get a SQLFeatureNotSupportedException with the only information being the message "feature not supported" and the vendor code -1500. What I'm doing is a basic insertion i...
In WebSphere 6.1 I have created a datasource to an Oracle 11g instance using the thin JDBC client.
In Oracle I have two users, one existing and another newly created.
My websphere datasource is OK if I use the component-managed authentication alias of the existing user, but fails with "invalid user/password" message if I use the alias ...
Using the JDBC driver oracle.jdbc.xa.client.OracleXADataSource, what is the correct format of the JDBC URL? The thin format of
jdbc:oracle:thin:@host:port:sid
does not work. WebSphere is reporting that the given url (which is otherwise correct) is invalid.
The test connection operation failed for data source Oracle MyDB (XA) on
se...
how can I do the analogous to SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40') in PostgreSQL, but in JDBC?
thanks
...
We have a commercial software product under development. It supports Oracle, MySQL, and SQL*Server backends (we also use H2 for testing). We do our integration testing against those different database using JDBC drivers of a specific version. Maven handles all this beautifully.
When packaging the application as a WAR, is it ok if we ...
Is it possible to make a Unix socket connection to MySql with Java to avoid JDBC's TCP/IP overhead?
Does anyone know a library (or a few libraries, perhaps) that makes this possible?
...
In the Oracle JDBC driver, there is an option to cache prepared statements. My understanding of this is that the prepared statements are precompiled by the driver, then cached, which improves performance for cached prepared statements.
My question is, does this mean that the database never has to compile those prepared statements? Does ...
I need to use full text search but the tables that I am using in my web application use the INNODB engine, from what I read JDBC does not have support for Mysql triggers and I am supposed to deploy the project on the course server so installing tools such as sphinxs is not possible, could someone please suggest a method to perform a full...
I have two select statements and make 'union all' for these two statements. Then, I use the PreparedStatement and when I setString to this preparedStatement, it shows "java.sql.SQLException: Missing IN or OUT parameter at index:: 2".
After I toured around google, some people say that for each "?" in sql statment, I should write setStri...
As far as I know, when using JDBC, it is not possible to remotely call Oracle procedures that have records or booleans as arguments. I wonder if there is any, not necessarily Java-based, interface that does not have such limitations. I know about JBublisher, but I'd rather there was some way that would not require to install any wrappers...
Hi i am trying to parse a string into a java.sql.date
Here is what i am doing
private static SimpleDateFormat sdfout = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
try{
String date = "2010.09.30.13.18";
task.setDueDate(new java.sql.Date(sdfout.parse(date).getTime()));
}
The problem is that i only get th...
I am using the Java Joda Time library, and have a date and time stored as an org.joda.time.DateTime object.
How can I reliably convert this DateTime object into a String that will be parsed correctly by SQL server (including timezone), such that I can use it in an INSERT SQL statement?
...
A couple of years ago I wrote a small utility to move data from an Oracle db to a Postgres db. I used Java and JDBC to accomplish this because I wanted Java to handle the data formatting for data used in a prepared statement to do the insert. The original version of the utility assumed that the table names and column names were the same...
try {
pst=con.prepareStatement("insert into stud values(?,?,?,?,?,?,?,?,?)");
pst.setString(1,s1);
pst.setString(2,s2);
pst.setString(3,s3);
pst.setString(4,s4);
pst.setString(5,s5);
pst.setString(6,s6);
pst.setString(7,s7);
pst.setString(8,s8);
pst.setString(9,s9);
int val=pst.executeUpdate();...
I have a mysql database with unicode text strings in it. My JSF application (running on tomcat 6) can read these unicode strings out and display them correctly in the browser. All the html charsets are set to UTF-8.
When I save my object, even having made no changes, Hibernate persists it back to the database. If I look directly in the ...
In my app I need to do a lot of INSERTS. Its a Java app and I am using plain JDBC to execute the queries. The DB being Oracle. I have enabled batching though, so it saves me network latencies to execute queries. But the queries execute serially as separate INSERTs:
insert into some_table (col1, col2) values (val1, val2)
insert into some...
I have the following calls in one of my classes
@Override
public Integer save(NewsItem item){
ConnectionPool pool = new ConnectionPool();
Connection connection = pool.getConnection();
PreparedStatement ps = null;
try{
String query = "INSERT INTO newsItem (type,title,content,link,layout,imageUri,timestamp)" +
...
Hi to all.
I've recently got a bug that's somewhat weird for me. Let's consider that we have a table with a column of FLOAT(8, 3). Let's also consider we have a validated table editor accessible via web browser. The table editor supports the client-side validation for every column, and does not allow to put floats that are not in the ra...
According to JAVA documentation, Connection#commit() can throw SQLException. My question is whether or not a rollback should still be issued in this scenario.
For example:
Connection con = null;
try {
// assume this method returns an opened connection with setAutoCommit(false)
con = createConnection();
// do DB stuff
...