jdbc

Refreshing data in a java.sql.ResultSet

I have a java.sql.ResultSet object containg data from a query that was run. How do I refresh the data in the ResultSet to reflect the current data in the database? Thanks! ...

JDBC CallableStatement and Oracle SYS_REFCURSOR IN parameters?

Pretty much what it says in the title, how the hell is this supposed to be done? Basically i need to pass a null (empty?) ref cursor as an IN parameter to a stored procedure. /** spring's PreparedStatementSetter#setValues(...) */ public void setValues(PreparedStatement ps) throws SQLException { CallableStatement cs = (CallableState...

What transaction manager should I use for JBDC template When using JPA ?

I am using standard JPA transaction manager for my JPA transactions. However, now I want to add some JDBC entities which will share the same 'datasource'. How can I make the JDBC operations transactional with spring transaction? Do I need to swith to JTA transaction managers? Is it possible to use both JPA & JDBC transactional service wi...

Call to DataSource.getConnection not returning the expected connection.

I have the following code: Hashtable env1 = new Hashtable(); env1.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); log.info("Executed step 1"); env1.put(javax.naming.Context.PROVIDER_URL, "iiop://myhost.com:9301"); log.info("Executed step 2");...

Check if edit is valid for database ms-access

I want to be able to check if I can edit a cell in a database with a new object Example method declaration: something.isValid(Object newObject, row, column); Example cases: If the editing cell stores an Number and I give it a String, the method will return false... If the editing cell has to be different than every other entry (uni...

DriverManager always returns my custom driver regardless of the connection URL

I am writing a driver to act as a wrapper around two separate MySQL connections (to distributed databases). Basically, the goal is to enable interaction with my driver for all applications instead of requiring the application to sort out which database holds the desired data. Most of the code for this is in place, but I'm having a prob...

Is there a way to listen for changes in an MySQL database table using Java and JDBC?

I have a number of users which are logged in at a time in my desktop application. They are working on the same table (create, read, update, delete data) so I have to update their views, to reflect changes, every few seconds - currently I am thinking to use a different thread to do that. I am using the MySQL database engine. Is there ...

Character problem at displaying the result of a query

I am not good at jsp but I wondered what can cause such a problem when every other strings are displayed well: a JSP file queries information of people by their name at Contact (MS Exchange). the query returns the full info of the person; and the first, last names are printed. Last names with apostrophes (Ex: O'reilly) aren't displayed ...

Get query from java.sql.PreparedStatement

In my code I am using java.sql.PreparedStatement. I then execute the setString() method to populate the wildcards of the prepared statement. Is there a way for me to retrieve (and print out) the final query before the executeQuery() method is called and the query is executed? I Just want this for debugging purposes. Thanks. ...

what is the best way to put resultset data into a text file?

I want to put all the data in the resultset into a text file in the same order. Is there any method to get data in all the rows at once and write to a file or have to write it row by row? ...

Using an ODBC application with a JDBC driver

My company uses Vertica. We have Python applications that connect to it with pyodbc. I do most of my development on a Mac (Snow Leopard) and unfortunately Vertica has not released ODBC drivers for Mac. They do have JDBC drivers though. I don't think developing in Jython is a good compromise. Is there any way to use JDBC drivers with...

How can we run .sql file from java without using JDBC?

I want to run a .sql file from java without using jdbc on windows 7. I am trying with java runtime class which executes the system commands. But my java is running with only user privileges and the command needs Administrator privileges. The command that am using to run is "sqlplus /nolog @sqlscript.sql". ...

Storing Result set into an array

i know this should be simpel and im probably staring straight at the problem but once again im stuck and need the help of the code gurus. im trying too take one row from a column in jdbc, and put them in an array. i do this as follows: public void fillContactList() { createConnection(); try { ...

Array not showing in Jlist but filled in console

Hey there. been a busy debugger today. ill give ths short version. ive made an array list that takes names from a database. then i put the contents of the arraylist into an array of strings. now i want too display the arrays contents in a JList. the weird thing is it was working earlier. and ive two methods. ones just a little practi...

how to get the result query one by one in jsp and mysql

I am trying to implement as Online Mock exam in JSP, but I have a problem to get the questions one by one, it get connceted for the first time, and show me the first question and answers, but when I click on "next" again, it still show me the first question, I think by clicking on "next" it start querying again. please help me. this is ...

How to Configure SSL over Database in Spring?

Hi, I want to add SSL security in the Database layer. I am using Struts2.1.6, Spring 2.5, JBOSS 5.0 and Informix 11.5. Any idea how to do this? I have researched through a lot on the internet but could not find any solution. Please suggest! Here is my datasource and entity manager beans which is working perfect without SSL: ...

JDBC/OSGi and how to dynamically load drivers without explicitly stating dependencies in the bundle?

Hi, This is a biggie. I have a well-structured yet monolithic code base that has a primitive modular architecture (all modules implement interfaces yet share the same classpath). I realize the folly of this approach and the problems it represents when I go to deploy on application servers that may have different conflicting versions of...

Impact of java.sql.Connection.close() on java.sql.Statement objects and the like

Does closing a java.sql.Connection also close all the statements, prepared statements, etc. obtained from that connection? Or is there going to be memory leak if I close the connection but leave the statements, etc. unclosed? ...

How to create a jdbc connection in java

How to create a jdbc connection in java? ...

Updating ResultSets with SQL Array types in JDBC / PostgreSQL

I'm trying to use a SQL Array type with PostgreSQL 8.4 and the JDBC4 driver. My column is defined as follows: nicknames CHARACTER VARYING(255)[] NOT NULL and I'm trying to update it thusly: row.updateArray("nicknames", connection.createArrayOf("CHARACTER VARYING", p.getNicknames().toArray())); (p.getNicknames() r...