jdbc

Can I optimize this code??

I am trying to retrieve the data from the table and convert each row into CSV format like s12, james, 24, 1232, Salaried The below code does the job, but takes a long time, with tables of rows exceeding 1,00,000. Please advise on optimizing technique: while(rset1.next()!=false) { sr=sr+"\n"; ...

No Row inserted when using hibernate example

Hi, I, trying to use Hibernate 3.5.3 with Postgresql 8.4 and PostGreSQL-8.4.701.jdbc4.jar and after transaction completed no actually data inserted into table. this is the table: CREATE TABLE doolloop2.dluser ( id bigint NOT NULL, firstname character varying(255), lastname character varying(255), email character varying(2...

JDBC - setAutoCommit for read only operation

Let's say I have a common method which creates a DB connection: Connection getConnection() throws SQLException { Connection con = ... // create the connection con.setAutoCommit(false); return con; } I put the setAutoCommit(false) call here so that callers of this method never have to worry about setting it. However, is thi...

JDBC ResultSet.absolute() vs. Limit

What's the preferred method to fetch a subset of records from the database? Use rs.absolute() or Limit? ...

Alternative way to load DB driver in Java.

Is there any other way to load DB driver than class.forName? This question is asked by my friend and looking for answer. Any help would be very helpful. ...

java sql connectivity

I have created a user dsn named "harshi" To insert rows in a table getting data from Java code I want to insert in SQL table. The connection statement is: String url = "jdbc:odbc:Harshi"; Connection conn = DriverManager.getConnection(url,"",""); Statement st = conn.createStatement(); Still I am getting output as: Got an excepti...

Any idea on how to implement these database tables to Java?

I've started to develop my own mini project in restaurant reservation to improve my Java skills. At the moment, I create a table consists of number of tables in the restaurant (column) and time interval during the day (row). So for example, if someone booked a table at 11:00 on Table 4, that cell will become reserved and mark as b...

How to do a backup from a Postgresql-DB via JDBC?

In our application, we've implemented an automatic DB migration triggered from within our code. Now we want to backup the existing DB before doing any migration. Can anyone explain how to do a full backup of a Postgresql-DB via JDBC from within Java code? Update: it doesn't work via JDBC. Here some working code to the response of Fra...

error while inserting symbol in database with JPA

I am using JPA to insert into Mysql database and it is not able to persist symbols like double quotes(") or euro etc. instead of that it persist Que mark (?) ...

Best way to manage DB connections without JNDI

I have a website, in which currently I am getting 1000 page views. I am expecting it will go around 30k per day in future. Now the problem for me to manage the DB connections. At present I am just connecting to DB directly from java program. I know it is worst design in the world. But for time being I have written like that. I have plan ...

SQLException: No suitable driver found for jdbc:derby://localhost:1527

I get this error in Netbeans: java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/ How is this caused and how can I solve it? ...

Copying Java ResultSet

I have a java.sql.ResultSet object that I need to update. However the resultset is not updatable. Unfortunately this is a constraint on the particular framework I'm using. What I'm trying to achieve here is taking data from a database, then manipulating a small amount of the data and finally the data is being written to a CSV file. At ...

exhausted resultset error when i get the name of the columns

hi, i'm trying to get the type and the name of the result and when enter in the loop, excuting somo instructions about the metadata the resulset.next changed from true to false, and give the error java.sql.SqlExcepcion exhausted resultset. Any ideas? i really dont know how solved it because i read the post with the solution of this probl...

Different value of date display between database and data table

I have a problem with display of dates from Oracle database in a Java webapplication using a JSF datatable. The displayed date differs from the date in the database. Here are some examples: in oracle: 24-APR-87 display in datatable: Apr 23, 1987 in oracle: 01-JAN-10 display in datatable: Dec 31, 2009 in oracle: 13-MAR-89 display in...

Beanshell jdbc connection

Hi, i want to connect to my database using beanshell script. my code works with java but beanshell doesn't work with the same code. Class not found exception will be thrown. does it have other usage or can't i connect to database with beanshell? Thanks, Bilal ...

Calling MySql functions remotely fails

When I try to call user defined functions using remote connection it gives me error. The thing is query without any functions runs fine for remote connection. So how can I call functions remotely. Query : select jobcardid,sonno,sonnumber,getSalesOrderCountByStatus('completed',1)as finished,getSalesOrderCountByStatus('pending',sonnumbe...

Error Getting JDBC Connection

Hi there, im having problem getting a JDBC connection from a EJB SessionBean.The error which is being throwing is: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous war...

Java PreparedStatement UTF-8 character problem

Hi All; I have a prepared statement: PreparedStatement st; and at my code i try to use st.setString method. st.setString(1, userName); Value of userName is şakça. setString methods changes 'şakça' to '?akça'. It doesnt recognize UTF-8 characters. How can i solve this problem? Thanks. ...

beanshell jdbc connection, class loading

Hi folks, i want to connect to a hsqldb in beanshell script. i had problems while loading class, i wrote it before and it was replied. the code looks like that: Connection conn = null; try { getClass("org.hsqldb.jdbcDriver").newInstance(); conn = DriverManager.getConnection("jdbc:hsqldb:file:C:/testd...

Escaping single quotes in table SQL queries

Using java.sql.Preparedstatement implies the escaping of characters will be done while parsing the queries, this does happen also when I have single quotes in my data but when I have single quotes in my table name itself the query does not work (I am using Oracle 11g). Here's my code: Class.forName("oracle.jdbc.OracleDriver"); con = Dr...