jdbc

A great tutorial of mysql to jump right in?

I will use mysql as a database choice with my java. What is the best way to learn it quickly and become productive super fast... well I am jsut trying to learn it as I am working on the project involving it. I my goal is to be able to create/administer/design tables for Mysql database program in Java against it (with tomcat) Thank...

JDBC: How can I query by time in Oracle?

I have this JDBC SQL query: select * from table where TX_DATE = {d '2009-01-05'} and TX_TIME = {t '15:23:39'} This returns some rows. Note that, since Oracle has no TIME type, both columns are of type DATE. But it fails when I use JDBC parameters: select * from table where TX_DATE = ? and TX_TIME = ? where the first parameter is n...

JDBC postgres vacuum timeout

I'm trying to vacuum my Postgres database by running the following SQL instruction within Java: vacuum verbose analyze Sometimes it just seems to "hang" is there any clean way to abort the process? I have tried SET statement_timeout TO XXXX But I get the error message "VACCUM cannot run inside the transaction block" ...

PreparedStatement is executed on prepareStatement on SQL Server

We have a Java code similar to the following: PreparedStatement stmt = connection.prepareStatement("drop login tmp"); int result = stmt.executeUpdate(); When running through a debugger, it seems that our SQL statement is executed after the first line is executed, and even before the second line is executed. When the second line is exe...

Java Database Connectivity (JDBC) session handling?

I am using MySql 5 Hi I am using/start learing JDBC. Well I got stuck here: After an user authenticated, I would like to start/generate the session for the user. How do I do that? In php, I know, we can start by using the "start_session()" function. Is there any similar function in JDBC? If there is no such kind of functions, how do w...

Query.executeUpdate() results in XAResource exception

I'm running Spring and Hibernate's implementation of JPA on Sun's GlassFish Enterprise Server with MySQL. When I try to delete stuff from the database: Query q = entityManager.createQuery("DELETE FROM SomeEntity e"); q.executeUpdate(); I get the error: Caused by: java.sql.SQLException: Error in allocating a connection. Cause: java.l...

Is JDBC secure?

I am new to JDBC, and the new project require me to use JDBC. What I want to know is, is the JDBC secure? How to prevent "Mysql Injection"-like problem? What are the security issues that I need to pay attention when I use JDBC? And how to ensure, I mean optimize the security, in order to prevent from hackers to hack the database? ...

Using Spring's JDBC support to get output parameters

I'm using Spring's JDBC support to run SQL queries and updates on an Oracle database. I'd like to insert a row and then get the key that it was assigned (using an Oracle sequence). In normal JDBC code, I would include a RETURNING INTO clause and then register an output parameter (well described here) However, I would like to just use ...

JDBC + Java Query execution error

I'm getting this exception java.sql.SQLException: Unknown column 'auyu' in 'where clause' My Query and method in my database facade class. db.save("delete from users where name = auyu"); public static void save(String sql) throws Exception { new DBFacade().connect(); synchronized (c) { c.createStatement()...

JDBC- postgres, connection refused

This is my first time using java to access databases, so I probably have a simple mistake here, but when I go to retrieve my connection from a remote database I have access to, I get a connection refused. Here's the code in question: String url = "jdbc:postgresql:url.isformatted.like.this/database"; try { conn = DriverManager.getC...

Creating triggers over JDBC (oracle)

Does anyone know how to get triggers created over JDBC. It appears that the problem is to do with the semicolon. Any feedback much appreciated. The following SQL works when run on the database, but not when run using the following Java code: Connection c=null; Statement s=null; try { c=dataSource.getConnection(); ...

How to set list of parameters on prepared statement?

i have a list of names e.g.: List<String> names = ... names.add('charles'); ... and a statement: PreparedStatement stmt = conn.prepareStatement('select * from person where name in ( ? )'); how to do the following: stmt.setParameterList(1,names); Is there a workaround? can someone explain why this method is missing? using: ja...

Java conectivity with PostgreSQL

can some one please tell me how to connect java file to postgresql database (if posible wit code n explanation) ...

How to make Java work with SQL Server?

I know this is a basic question, but I can't seem to find an answer and I apologize, if this question is way too stupid, but here we go: I am supposed to work with SQL Server (no problem so far) and with Java (love java, so no problem here either), but now: What am I supposed to do to make the combination work? I got: JRE 1.6 and the sq...

Java not giving Error!

Here is my code - i am simply checking my MySQL database connection. But first i have compiled and run the program successfully. but then i have commented the line Class.forName . Still when i compile it runs successfully, without any error.Why? import java.sql.Connection; import java.sql.DriverManager; public class FirstJbdc { pu...

Netbeans with Oracle connection java.lang.ClassNotFoundException

I use NetBeans 6.5 . When I try to run the following code : package com.afrikbrain.numeroteur16; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author */ public class NumeroteurTest { public NumeroteurTest() { } ...

What does Statement.setFetchSize(nSize) method really do?

hi. i have this really big table with some millions of records every day and in the end of every day i am extracting all the records of the previous day. i am doing this like String SQL = "select col1, col2, coln from mytable where timecol = yesterday"; Statement.executeQuery(SQL); but the problem is that this program takes like...

Writing desktop app that uses database. Suggestions for how to manage user access to tables?

I'm writing a depsktop application (in Java) that interacts with a database which stores mostly requirements documents,but I have a bit of a dilemma. Specifically, a problem with managing user access. To illustrate, I store all details on the folder structures in a single table. However, I would like to institute a user-group mechanism...

JDBC Thin Oracle 11g

Hi all, I am using oracle 11g. I write code to connect oracle database with java 1.6, but I can't connect to it. When configure the guide line to below: I have ojdbc6.jar,orai18n.jar, and class12.jar I set: Class_Path: %ORACLE_HOME%\jlib\orai18n.jar;r;%Oracle_home%\jdbc\ojdbc6.jar After that I run sample java code connect to oracl...

JDBC Query excecution

I am facing an issue while executing queries.I use the same resultSet and statement for excecuting all the queries.Now I face an intermittent SQlException saying that connection is already closed.Now we have to either have separate resultSet for each query or have lock like structure.Can anyone tell which is better.I think introducing lo...