jdbc

Oracle connection compression?

I have an application that uses JDBC to connect to Oracle 11g. Unfortunately, the machine my app is running on and the Oracle machine are connected via a somewhat low bandwidth connection. I haven't sniffed the connection, but I am pretty sure the data streaming across the connection is not compressed. For my application, I'm more con...

Importing a (mysql) database dump programmatically through Java

Hi All, How can I import a mysql database dump file (contains insert and create table statements) programmatically through a java program. I need this as the setup phase of a unit test. Unfortunately this doesn't work: Connection conn = dbConnectionSource.getConnection(); Statement stmt = conn.createStatement(); stmt.execute(FileUtil...

Problem With Data Insertion in Ms Access

import java.sql.*; public class NewConnection{ private static Connection con; private static ResultSet rs; private static Statement sm; private static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver"; private static final String URL = "jdbc:odbc:Driver={Microsoft Access driver (*.mdb)};DBQ=E:\\Database.mdb;"; pr...

Problem in data insertion in Ms access..But Code runs fine

import java.sql.*; // I think this is a poor abstraction public class NewConnection { /*very important: dont use statics for your Connection, Statement and Query objects, since they can and will be overriden by other Instances of your NewConnection.*/ // There's no need at all for having class members here. It's actually // a ...

Resultset To List

I want to convert my Resultset to List in my JSP page. and want to display all the values. This is my query: SELECT userId, userName FROM user; I have executed that using preparedstatement and got the Resultset. But how to convert it as a List and want to display the result like this: userID userName ------------------ 1001 ...

Open Office Database Error(Shows Exception While running)

## This is the code i m runnig in linux ubuntu.. ## import java.sql.*; /** * * @author spk */ public class Connectionsetting { private static Connection con; private static java.sql.Statement sm; private static ResultSet rs; public void close() { try { sm.close(); con.clo...

c3p0 ResultSet.unwrap throws an AbstractMethodError

I have a ResultSet object that I need to turn into an OracleResultSet so that I can call the getOPAQUE(String) method on it. I'm using c3p0 as my connection pool. The problem is that c3p0 wraps ResultSets in NewProxyResultSet objects. This shouldn't be a problem because I should just be able to call unwrap on the ResultSet like this: r...

Value from last inserted row in DB

Is there some way to get a value from the last inserted row? I am inserting a row where the PK will automatically increase due to sequence created, and I would like to get this sequence number. Only the PK is guaranteed to be unique in the table. I am using Java with a JDBC and Oracle. I forgot to add that I would like to retrieve thi...

Externalizing tomcat jdbc connection pool information for different environments

Greetings, I'm looking for a good solution for externalizing the JNDI connection pool information in context.xml of a war so that as the application moves from dev to QA to prod, the war file won't need to be recompiled. Ideally the url, driver, username and password would be variablized and then populated by means of a properties file...

Accessing Unicode telugu text from Ms-Access Database in Java

I have an MS-Access database ( A English-telugu Dictionary database) which contains a table storing English words and telugu meanings. I am writing a dictionary program in Java which queries the database for a keyword entered by the user and display the telugu meaning. My Program is working fine till I get the data from the database, b...

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException when using JDBC to access remote MySQL database

/** * */ package ORM; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * @author Gwilym * @version 0.0 */ public class DatabaseConnection { private String userName=""; private String password=""; private String host=""; Connection conn; /** * @param userName * @param passwo...

ResultSet to Pagination

How do I convert Resultset object to a paginated view on a JSP? For example, this is my query and result set: pst = con.prepareStatement("select userName, job, place from contact"); rs = pst.executeQuery(); ...

How to catch a specific exceptions in JDBC?

How to catch a specific exceptions in JDBC? Examples: primary key exception or foreign key exception. ...

glassfish error

SEVERE: javax.naming.NamingException: Lookup failed for 'jdbc:mysql://localhost:3306/sample ' in SerialContext [Root exception is javax.naming.NameNotFoundException: jdbc:mysql:] what to do to rectify? i am running jsp code in netbeans and i am using mysql as dbms ...

MySQL Connection Error with JSP

Hello, I am trying to connect to mysql database from jsp page. The connection code is as below InitialContext ic=new InitialContext(); DataSource ds=(DataSource)ic.lookup("jdbc:mysql://localhost:3306/"); Connection con=ds.getConnection(); Statement stmt = con.createStatement(); when i open the page i get the foll...

what is best way to paging big Resultset -Java

hi, i am looking for best aproach from perfomance point of view , to show Resultset on webpage partially , lets say by 10 item per page and if user want to see more result, he pressing "next" btn . i think (probablly wrong) it should be new request to the Server when "Next" button is pressed ?? currentlly i trying to learn Java,GWT ...

enterprise with jdbc

I have enterprise project, but all queries are implemented using oracle stored procedures, I use jbdc and Spring framework to get results like this : public class HoaDonDAOimpl extends JdbcDaoSupport implements HoaDonDAO { public List<HoaDon> getDsTatcaHoadonPhathanh(int vthang, int vnam, String vmaDvqltb) throws Exception { Ca...

Java: ResultSet closing strategy, apart from closing it in finally

I am facing ORA-01000: maximum open cursors exceeded although I am closing the resultsets in finally block. But I suspect there is some trouble with my legacy code, below is my pseudo-code while (someCondition) { rs1=executePreparedStatementNew(query1,param1,""); //do something with rs1 rs1=executePreparedStatementNew(query2,param2,"")...

sql statement "into outfile" not working with jdbc

I am attempting to add an "export to CSV" feature to a webapp that displays data from a MySQL database. I have a written a "queryExecuter" class to execute queries from my servlet. I have used this to successfully execute insert queries so I know the connection works etc however queries with the "into outfile" statement are simply not ...

Best way to use a PostgreSQL database as a simple key value store.

I am being required to use a postgreSQL database and it will replace my current use of berkeleyDB. Although; I realize this is not an ideal situation, it is beyond my control. So the question is... If you were required to make postgreSQL into a key value store how would you go about doing this, while making it as efficient as possible?...