jdbc

designing database tables using JDBC

I am creating a users table using JDBC and mysql, each user has a permissions list that comprises Integer values. I am wondering if I should use an array for storing these values and then have only 1 record for this user in the table, or simply create a new table that comprises 2 columns: user ID and permissions, and then have multiple ...

display an image stored in the database with Java

I have a problem when I want to display an image stored in the database with OLE using JAVA. ...

Why am I getting the error SQLException: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1

I am using the following code for uploading keywords & count to an Excel file. I am having the keyword_id as primary key for that one. I am having the two columns in the Excel file. 1.keyword and 2.count my code is: while (rs.next()) { System.out.println("inside "); String keyword = rs.getString(1); int count = rs.getInt(2...

Where are JDBC4 annotations ?

Some time ago, jdk 6 announced JDBC4 with the "Annotation-Based SQL Queries". I was looking for testing the approach but didn't find the required classes (like java.sql.BasicQuery) in the JDK 6. Googling a little on the subject, I found a thread on java.net that tells these "Ease of User" features haven't finally been included in the JD...

JDBC ResultSet total rows

I am implementing Paging in my application. For this i run a query and get a resultset. Now i want to get total no of records in this resultset for my paging calculation. How can i get ? i dont want to execute a extra sql which gives me total rows ...

JDBC character encoding

Hi there, I have a Java Web application using GlassFish 3, JSF2.0 (facelets) and JPA (EclipseLink) on MySQL (URL: jdbc:mysql://localhost:3306/administer). The problem I'm facing is that if I'm saving entities to the database with the update() method, String data loses integrity; '?' is shown instead of some characters. The server, page...

How to query for Double with Spring JDBC template query

How do one query for a double with the Spring JDBC temple? For example: public double getAverageScore() { return jdbctemplate.queryFor???("select avg(score) from test"); } There are queryForInt and queryForLong, but no queryForDouble ...

Database connection timeout

Hi I have read so many articles on the Internet about this problem but none seem to have a clear solution. Please could someone give me a definite answer as to why I am getting database timeouts. The app is a GWT app that is being hosted on a Tomcat 5.5 server. I use spring and the session factory is created in the applicationContext.xm...

Oracle Connection exception via JDBC

I have installed Oracle 11gR2 on my machine, now when i try to connect to it using IP address as 'localhost' or '127.0.0.1' there is no issue, but when I use ip address of machine '192.168.1.6' it throws exception: Io exception: Then Network Adapter could not establish the connection. I have installed ms loopback adapter prior to instal...

NullPointerException with CallableStatement.getResultSet()

Hello, I have a stored proc in SQL Server 2005, which looks like the following (simplified) CREATE PROCEDURE FOO @PARAMS AS BEGIN -- STEP 1: POPULATE tmp_table DECLARE @tmp_table TABLE (...) INSERT INTO @tmp_table SELECT * FROM BAR -- STEP 2: USE @tmp_table FOR FINAL SELECT SELECT abc, pqr FROM BAZ JOIN @tmp_table...

Sybase: programmatically turn off foreign key checks

Hi, I need to do bulk inserts/updates/deletes on a table-by-table basis via JDBC. Database is Sybase. Because of FK checks, I can't do this, because I temporarily violate integrity. In MySQL I can easily turn off and on constraint checks, by issuing a simple command. Is there some way to do the same in Sybase? Thanks. ...

Failed to execute stored procedure from the JDBC code using mysql connection

Hi, I have one database. I executed a stored procedure on it. I wrote some JDBC code to connect to this database. When I am calling this stored procedure from my JDBC code it is throwing SQLException. One interesting thing I found is that I have one user other than root user. This user has all the privileges to this database where th...

Getting the count of rows in a Java resultset

Hello Does anyone know a better way of getting the number of rows in a Java resultset returned from a MySQL database? I'm currently using this: public static int getResultSetRowCount(ResultSet resultSet) { int size = 0; try { resultSet.last(); size = resultSet.getRow(); resultSet.beforeFirst(); } ...

how to store BigInteger values in oracle database.

I have connected Java program to Oracle database using JDBC. I want to store BigInteger values(512 bits) in the database. What should be the type of the column? I m trying like this: I have taken a column of number type in the database. I converted BigInteger to BigDecimal like this: BigInteger b=new BigInteger("577985757095780257907...

how to display a table retrieved from database to a jsp page via a controller page in Struts framework

i have created a model class to connect with database with a function that retrives a table data.now this function should return whole resultset back to a Controller action page. further controller action should send the data to jsp page for client viewing. or simply how to hold Resultset data from query like..select * from table ...

Microsoft ODBC for Oracle and JDBC

Is the Microsoft ODBC driver for Oracle compatible with JDBC? If so, could an example be given? ...

Oracle Cursor and JDBC ODBC

I have some procedures to execute in the database that has an OUT REFCURSOR parameter. When I am connecting with the JDBC thin client, everything works fine. However, if I were to change the connection string to refer to the ODBC data source pointing to the same database, those procedures will fail. The procedures that do not use an OUT...

MySql too many connections

I hate to bring up a question which is widely asked on the web, but I cant seem to solve it. I started a project a while back and after a month of testing, I hit a "Too many connections" error. I looked into it, and "Solved" it by increasing the max_connections. This then worked. Since then more and more people started to use it, and i...

Hibernate+PostgreSQL throws JDBCConnectionException: Cannot open connection

I write an Test Java APP and it works right BUt this Web app throws an exception like that with to same cfg.xml file <property name="hibernate.bytecode.use_reflection_optimizer">false</property> <property name="hibernate.connection.autocommit">true</property> <property name="hibernate.connection.release_mode">auto</property> <property n...

Java - JDBC driver and MySQL database connection issues

Ok - I found the driver version that goes with the database.. however now I get the following. Got an exception! Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.ConnectException MESSAGE: Connection timed out: connect STACKTRACE: java.net.ConnectException: Conne...