jdbc

Extremely slow DB2 connectivity in Java

I am trying to connect to a IBM DB2 9 database on a Linux server from my Java application. I am using db2jcc.jar (DB2 Universal JDBC Driver). Establishing a connection takes a ridiculous amount of time? What could be wrong? I know there a lot of factors that could cause this, but I am willing to get down to the root cause. Please help me...

how to reload jsp page on every request?

i have a jsp page with jdbc connection and on first load it shows the data accurately but after that it shows empty tables i think 2nd time it loads from memory not from server what is problem behind i don't know ok here are the details i have a servlet that maintains the session for a user that log in and then after creating the s...

Spring JDBC DAO

Hi! Im learning Spring (2 and 3) and i got this method in a ClientDao public Client getClient(int id) { List<Client> clients= getSimpleJdbcTemplate().query( CLIENT_GET, new RowMapper<Client>() { public Client mapRow(ResultSet rs, int rowNum) throws SQLException { Client...

when to roll back a jdbc transaction

I have been reading an interesting statement in http://download.oracle.com/javase/tutorial/jdbc/basics/transactions.html The interesting part is: "Catching an SQLException tells you that something is wrong, but it does not tell you what was or was not committed. Since you cannot count on the fact that nothing was committed, calling the ...

IllegalArgumentException with Date value in jdbc; Openbase sql

I have a WebObjects app, Openbase db, and I'm getting a never before seen exception when doing a raw rows (non ORM) query during a batch operation. It looks like the jdbc adaptor is throwing on a date value in the db and is unable to coerce the raw data into the proper type. It literally kills the app and ends the export process. Here's ...

JTDS and JBOSS JDBC Connection Pool Problem, any solution? Maybe a custom ValidConnectionChecker?

Hello, I'm facing a weird production problem. Environment is the following: JBOSS 4.0.2 SQL Server 2005 Driver JTDS 1.2.5 From time to time the following szenario occurs. A SQL command fails to Excute with java.sql.SQLException: I/O Error: Read timed out (I can live with that, if it just happens twice a day or so) But from ...

Getting "The column name xxx is not valid" exception when trying to combine columns

I am trying to combine two columns in SQL query but getting the following exception in java.sql.ResultSet's FindColumn method: JdbcSqlException: The column name FullName is not valid. Column: 'FullName' Here is my SQL query SELECT U.FirstName + ' ' + U.LastName AS FullName FROM User as U Anyone? Please note that query runs ...

ResultSet using query arguments like in jdbcTemplate

Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something like: int length = 10; ResultSet rs = stmt.executeQuery("select MyTable.COLOR from MyTable where MyTable.LENGTH = ?", new Object[] { length }); is it possible? Thank you. ...

JTDS Connection problems to SQL Server - Works on 2000 but not 2005

I've been trying to get a java application connecting via the jtds jdbc to a couple of SQL servers. I have to connect via windows authentication. The connection string specified is: String connectionString = _"jdbc:jtds:sqlserver://"+server+":"+port+"/"+database+";domain="+domain;_ and I am getting the connection via: con = j...

JDBC general query execution

Is there a way, in JDBC, to execute a generic query ? I mean run something like execute(String strSql) where strSql could be a SELECT, an INSERT, an UPDATE,a CREATE,... or whatever. If no, how would you fix this up ? Proposed solution: @Override public void execQuery(String Query) throws SQLException { this.statement = this.connec...

SQL Prepared Statment to Create Table

I wanted to know of some way to create table on the fly based on user input(SQL Prepared Statement) CREATE TABLE ? ( First_Name char(50), Last_Name char(50) ) What should i put in place of question mark ...

get all indexes declared in database from java

Hi All, Is there any standard java api that returns the indexes declared in the database. I tried using the getIndexInfo() in database meta data but that seems to expect a table name as input and does not meet my requirements. Thx. ...

corejava Project help needed

Hi I'm Riya a B.Tech. student and i have to make a corejava project on the topic COLLEGE MANAGEMENT SYSTEM . I have created the required database using MS Access. I m facing problem in a code which i m attaching here. Actually i want to update a data in the data base so i have made 2 frames in one of them Roll no. is asked when it is e...

Cannot connect to Oracle DB from Java - ORA-12560: TNS:protocol adapter error

Hello, This is my first Java application I am creating (using Eclipse IDE) and the second Oracle based app (I'm a .NET/MSSQL guy for years). The first Oracle app I wrote in .NET did not have any issues, and I'm trying to connect to the same server. I have installed: 'Java 2 Platform, Enterprise Edition 1.4 SDK' 'Java DB `10.5.3.0' -'...

How to find the offending insertion from a BatchUpdateException?

When I have a BatchUpdateException as the result of a unique constraint violation is there a way for me to determine which record in the batch insert is in violation? For example let's say I'm performing a batch insert by calling PreparedStatement.executeBatch() and I catch the BatchUpdateException which has as it's cause "ORA-00001: un...

invalid sql statement in servlet

In login page i make validation that user is allowed to enter system , i make methode which validate user: boolean isValidUser(Connection con,String userName,String pass ){} it works correctly in desktop Application, but when i tried it in servlet it makes exception that table or view doesn't exist ??? but the table is aleady exist...

Can't return row id 17 by getGeneratedKeys()

I'm using sqlite JDBC 0.56 and the table is created using fts3 MY table is created by stat.executeUpdate("CREATE virtual TABLE doc using fts3 (doc_name , doc_path);"); seems the problem is caused by this virtual table. I tried to insert a set of record into a database and return the generated key. But I find that when the key is bec...

SQL_ASCII and Java remote access to PostgreSQL

Hallo, I tried to send the request to PostgreSQL 8.x that has character encoding SQL_ASCII. Sadly I can not convert it to UTF-8 in any way: neither sending connection properties client_encoding=UTF8 using springframework, nor "SET CLIENT_ENCODING = 'UTF8';" directly in jdbc transaction - nothing helps. On setting client encoding in jd...

JDBC Change Default Schema

Hi, I'm trying to connect to a sql server 2005 database via JDBC. I get the error: com.microsoft.sqlserver.jdbc.SQLServerException: The SELECT permission was denied on the object 'MyTable', database 'MyDatabase', schema 'dbo'. The schema I use to connect is "MyUser". How do I connect using MyUser as opposed to dbo? Thanks! ...

Getting a JDBC connection by JNDI in Spring JDBC

This page on Spring JDBC says The DataSourceUtils class … provides static methods to obtain connections from JNDI However the API doc for DataSourceUtils does not include the said static methods, as far as I can see. What am I missing? ...