jdbc

Why date is inserted as 02/10/0010 instead of 02/10/2010

I am inserting a record to orcle db through java application. The date value inserted as 02/10/0010 instead of 02/10/2010 HH:MM:SS AM/PM? I am using oracle jdbc connection. Does it problem with JDBC driver ? Any input on this. ...

JDBC error: End of stream was detected on a read

I have a problem accessing a database through a JDBC connection. End of stream was detected on a read The error occurs at several different points at random. I appreciate any help. ...

Is there a NoSQL / key-value store abstraction library like there is JDBC is for databases?

I have used many SQL abstraction libraries, such as ODBC, JDBC, and ActiveRecord. What are the abstraction options in the NoSQL / key-value store world? I am mostly asking this so that if I choose a key-value store then I can use an abstraction library and not be locked in, which I think is important given the number of key value store...

RETURN_GENERATED_KEYS doesn't work using JDBC ODBC

I'm trying to get insert ID while after inserting some data in my database. String sql = "INSERT INTO ADI.DUMMY(dummy_data) VALUES('from database logger')"; PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); int extUptReturn = ps.executeUpdate(sql); But I got this exception: Java exception: ''java.lan...

Insert Java variable using Java in SQL

I was trying to do: String sql = "INSERT INTO CURRENT_WEATHER_US VALUES("+city_code+", "+object.city+","+object.region+","+object.country+","+object.wind_chill+", "+object.wind_direction+", "+object.wind_speed+","+object.humidity+","+object.visibility+", "+object.pressure+","+object.rising+", "+object.sunrise+","+object.sunset+...

What happens to the original resultSet when it is returned from a method into a new object?

pseudo code to explain my self better. I'm learning Java at this point in time. if I have a method public resultSet getEverything() { resultSet rs = blabla; return rs } I can't rs.close() as I need to use it in the method I retrieve it hence then I will use it, and maybe 'close' the new resultSet I create. What happ...

Java JDBC Connection Lost after actionPerformed in Applet

If I run this code: http://www.danny92.pastebin.com/m1f84b972 You will see that my Database connection connects then disconnects after actionPerformed.... why? :( ...

MySQL + JAVA Exception: Before start of result set

try { PreparedStatement s = (PreparedStatement) conn.prepareStatement("SELECT voters.Check,count(*) FROM voting.voters where FirstName="+first+"and LastName="+last+" and SSN="+voter_ID); //java.sql.Statement k = conn.createStatement(); rs=s.executeQuery(); //s.executeQuery("SELECT voters.Check,count(*) F...

Hibernate: More than one relationship using the same join column

I'm using a legacy database schema with composite keys. I have an entity with two relationships and one of the join columns is shared. For example, Let's say i have a Student entity with two relationships Department and Course. Department uses dept_code column while Course uses dept_code and course_code colum. The domain model is such ...

How to enable implicitCachingEnabled (statement caching) from Tomcat for oracle?

Hi, I've been reading about implicitCachingEnabled and MaxStatements with the oracle jdbc driver. I've tried adding implicitCachingEnabled="true" into the server.xml for the datasource definition but it makes no difference. I've also noted other posts admittedly from a long time ago, where people have failed to get this setting to wor...

Updating RowSet if table content is changed?

Hey there, Is it possible to update/refresh a RowSet's in case the table content is changed (for e.g. another application modifies it)? So this way I 'always' have an up-to-date version of the table. I looked into RowSetListener, but these events seem to get invoked only if I make modifications to the RowSet directly. It would be enoug...

Execute dynamic sql and pl/sql in Java via web interface.

Hi. Currently I'm making sort of SQL command line interface for web-based application. It should act roughly like sqlPlus. I have encountered a problem how to execute sql's. They can be both as SQL and/or PL/SQL. First way I thought that I can split them (by ';' or ';/') and detect separately if it's sql select or delete/update/insert ...

get value from updated row

I'm trying to get the new rating from an UPDATE statement in java int userID = 99; String sql = "UPDATE table SET rating=rating+1 WHERE user_REF="+userID; statement.executeUpdate(sql); I can just do another SELECT statement, but isn't there a better way to retrieve the value or row while updating? ...

Java skips else condition

Hello I'm not sure why, but for some reason, the following code skips the else condition. I've tried just about everything I can think of, including switching the code blocks, but it still skips the else part. Basically, I want this method to return String temp = "no" if String docID that is passed to the method is not found in the FILE...

Java and PostgreSQL stored procedure - return registered as out parameter, causing issues with in parameters

I'm trying to call a PostgreSQL stored procedure from a Java app; the procedure has a DATE type parameter so I'm using a java.sql.Date type with CallableStatement.setDate(). However, executing the statement always results in an exception and the SQL logs show this: LOG: execute <unnamed>: select * from athlete.create_athlete($1,$2,$3,...

is there a standard way to define a JDBC Datasource for J2EE containers ?

I know that for JBoss you need a [name]-ds.xml file in the /deploy subdirectory of the appropriate instance. i dont have any experience with other J2EE containers, but im trying to stick to standards as much as possible. is there a standard way to define a JDBC datasource and deploy it ? if possible i'd like to include my datasource insi...

Oracle 9i Session Disconnections

[Cross-Posting from ServerFault] I am in a development environment, and our test Oracle 9i server has been misbehaving for a few days now. What happens is that we have our JDBC connections disconnecting after a few successful connections. We got this box set up by our IT department and handed over to. It is 'our problem', so options li...

App Java and hosting mysql

I have a Java application and I have to connect to a MySQL DB host in aruba.it. If I make a connection, aruba.it refuses that. How to solve this? ...

statement.execute() returns error with Slash at the end of PL/SQL

Hi. When executing pl/sql im obtaining an error : ORA-06550: line 1, column 316: PLS-00103: Encountered the symbol "/" The symbol "/" was ignored. PLSQL example: DECLARE SQL1 VARCHAR2 (1500); SQL2 VARCHAR2 (1500); BEGIN SQL1 := 'INSERT INTO das_html_caption VALUES (''test_test'')'; SQL2 := 'DELETE FROM das_html...

How to combine two ResultSets in Java?

I have two result sets (rs1 and rs2) having same fields. Now how to combine those two result sets into one so that duplicate rows are shown once. ...