jdbc

How to search and insert a value using java code?

String link = "http://hosted.ap.org"; I want to find whether the given url is already existing in the SQL DB under the table name "urls". If the given url is not found in that table i need to insert it in to that table. As I am a beginner in Java, I cannot really reach the exact code. Please advise on this regard on how to search t...

Retrieving a max date from DB2 in Java throwing wrong column type conversion exception

I have the following SQL that returns the max BILL_DATE based on some criteria. BILL_DATE is defined in the database as a DATE. SELECT MAX(BILL_DATE) FROM BILLTABLE WHERE col1 = ? and col2 = ? But when I read the value from the resultSet. bill.setBillDate(resultSet.getDate(1)); An exception is thrown: Invalid data conversion...

DAO methods and synchronized

The following are methods I currently have in an Abstract DAO class. If there are concurrent calls, are they safe as they are or should synchronization be used? I know synchronization should be used if there is a reference to an attribute outside the scope of a method but it's unclear to me how should things be handled with an outside re...

OSGi bundle starting problem

I have a Java application. I created a OSGi bundle and in Activator.start i added MyMain Class.main() .Application started but it have a problem with DB connection. 'java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.' If i start my application as an application it works fine. What is wrong? Thanks a l...

Chinese characters cannot be shown after saving and retrieving from Oracle Database

Up to this moment, I still have no luck to resolve this Chinese characters issue. I am using OC4J 9.0.4.1 with Oracle 10g Database (that is created with UTF-8). The situation is that my JSP page is set with pageencoding = UTF-8 already. I save some Chinese characters from web page to database (varchar2 column) via Thin Driver. In iSQL...

Moving a database with pg_dump and psql -U postgres db_name < ... results in "ERROR: relation "table_name" does not exist"

I moved my PostgresQL database from one hard drive to another using pg_dump -U postgres db_name > db_name.dump and then psql -U postgres db_name < db_name.dump I created the database db_name the same way in both instances. In the new database when I run my Java program with a JPA query (or a JDBC query) I get this error: "ERROR:...

jsp programming

I want to retieve username from database, but it gives empty page. What is wrong in my code? <html> <head> <title>verification</title> </head> <body> <%@ page import = "java.io.*" %> <%@ page import = "java.sql.*" %> <%@ page import = "java.lang.*" %> <% String eid = request.getParameter("ei...

Java - saving data in BLOB file

hi there, i want to save a lot of binary data files(pdf, images, office docs...) into one single "blob" file. now i'm not sure what is better, saving stuff with java Serializable and save things to disc or to use a database like sqlite to make things happen. or is there a third, maybe better way? my question is, how well do those method...

What does "java.sql.SQLException: No tables used" mean? Jboss + Hibernate

I am using JBoss 5.1 and I get the same error either with MySQL 5 or HSQLDB. Of course I already tried Google, but it seems that I am the only one who gets such an exception. Does anyone know what it means? ...

How to find that a SQL query executed has returned nothing?

import java.net.URL; import java.net.URLConnection; import java.sql.*; public class searchlink{ public static void main(String args[]) throws Exception { //String link="http://hosted.ap.org"; Connection con=null; Statement stmt=null; Statement stmtR=null; if(con==null){ SQLConnection.setURL("jdbc:sqlserver...

Connect to an oracle db in jdbc over an SSH tunnel

Currently we have to tunnel over SSH to access our Oracle database. In order to do this we have to make sure than putty or an equivalent program/script is running on the server doing this tunelling before the application is deployed to Tomcat/Glassfish/etc. Has anybody found a way to have java handle this tunneling transparently? Perh...

Finding the actual Job number for a particular JDBC SQL connection to iSeries?

I am using the JTOpen JDBC driver to connect to the iSeries (aka AS/400, IBM System-i, IBMi, WTH?!...). I am having problems with a particular statement and it appears I need to go back to the actual SQL job QSQSRVR (or QZDASOINIT?) to find more details. Only problem is that there are hundreds of these on the system. Is there an easy w...

What's the proper way to handle JDBC connections with Spring and DBCP?

I'm using the Spring MVC to build a thin layer on top of a SQL Server database. When I began testing, it seems that it doesn't handle stress very well :). I'm using Apache Commons DBCP to handle connection pooling and the data source. When I first attempted ~10-15 simultaneous connections, it used to hang and I'd have to restart the se...

How to gather user input in a JSP so that it can be stored in database

I dont know JSP. I have written the below Java JDBC code which must be integrated in JSP. import java.net.URL; import java.net.URLConnection; import java.sql.*; public class searchlink{ public static void main(String args[]) throws Exception { Connection con=null; Statement stmt=null; Statement stmtR=null; String link="h...

Spring Batch: migrating 1 to n relationship where n is potentially huge

I am experienced with Spring, but new to Spring Batch. Now I have the task to migrate a data structure from a simple structure in one database to a complexer one in the other. The data structure corresponds to an object hierarchy that I will name like this OldParent 1 --> n OldChild // old system NewParent 1 --> n NewChild // new syst...

Quering and writing to a file : errorcode 28

hi, I am getting this error when I try to query the database and write results to a file. It never occured before. java.sql.SQLException: Error writing file '/tmp/MYwADPLw' (Errcode: 28) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870) a...

JDBC connection pooling issue

Hello I have, I might say, a quite a big issue. I'm working on Java web application which use springs BasicDataSource to setup DB connection. I was testing the application locally and it works just fine... but, when application is online, connection to DB in some point just stuck. I was than investigating regarding connection pooling, ...

Query returns "No data found" JSP/Oracle

I've been looking this over for a while now and can't seem to pinpoint the problem. Does anything stand out that would cause a java.sql.SQLException: No data found ResultSet rs = null; rs = s.executeQuery("SELECT * FROM customer"); out.println("<tr><th>Customer ID</th><th>First Name</th>&nbsp;</th></tr>"); while(rs.next()) { ou...

I want to give JDBC connection to mysql. I dont wish have the data values inside my class people().

import java.util.*; import org.directwebremoting.util.Logger; public class People { public People() { people = new HashSet(); random = new Random(); log.debug("Generating a new set of random people"); for(int i = 0; i < 5; i++) people.add(getRandomPerson()); } public Set getAllPeople() { return people; } ...

how to store the data in a object array, which collected from data base?

Here, i have coded to get data from DB. I want to store the data in Object Array(POJO). How to do it? This code can also insert Data into DB, but omit it. import java.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sq...