jdbc

Dynamically select field names in a query with Spring JDBCTemplate

Hi, I have a problem with parameters replacing by Spring JdbcTemplate. I have this query : <bean id="fixQuery" class="java.lang.String"> <constructor-arg type="java.lang.String" value="select fa.id, fi.? from fix_ambulation fa left join fix_i18n fi on fa.translation_id = fi.id order by name...

Tapestry / JDBC - Storing Date

So Im using Tapestry and trying to store a date from a beaneditform into a simple Access database. It wont work, Im getting Null pointer exceptions and I cannot understand why. String onSuccess() { System.out.println("in on success!"); String nextPage = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection =...

Java string to double conversion.

Hi, I've been reading up on the net about the issues with handling float and double types in java. Unfortunately, the image is still not clear. Hence, i'm asking here direct. :( My MySQL table has various DECIMAL(m,d) columns. The m may range from 5 to 30. d stays a constant at 2. Question 1. What equivalent data-type should i be usi...

When would isSearchable return false for an Oracle JDBC column?

In what cases would a call to java.sql.ResultSetMetaData.isSearchable(int col) return false for an Oracle database? The documentation for the method doesn't really answer the question: "Indicates whether the designated column can be used in a where clause." I can think of only one case - when the column is the result of an aggregate...

How can I set the current schema for DB2 using Hibernate/JDBC?

I used to use currentSchema=MYSCHEMA; in my JDBC URL connection, but the version of DB2 we're using no longer supports that, showing the error 'The "currentSchema" property is not allowed on the target server'. I've tried using hibernate.default_schema, but it's not automatically adding the schema to my table names. I don't want to set t...

Spring Jdbc Template + MySQL = TransientDataAccessResourceException : Invalid Argument Value : Java.io.notSerializationException

I was using spring jdbc template to insert some data into the database and I was getting this error. Here is my code : JdbcTemplate insert = new JdbcTemplate(dataSource); for(ResultType result : response.getResultSet().getResult()) { Object[] args = new Object[] {result.getAddress(), result.getCity(), result...

mysql for dummies

I just started using MySQL and I just can see myself woking with strings! I mean the compiler can't catch errors like this and it's just a mess! Is there a wrapper or some kind of class I can add that does something as simple as making a function that adds a table and asks for args? I'm sure there is a tool like that but I can't find it...

Check to see if ResultSet is Null if not then get int

I want to be able to get check to see if there is a result in my resultset. Todo this i would execute: if(rs.next()){ boolean = true; } However i want to check to see if the value is in the database if so retrieve it: while(rs.next()) id = rs.getInt("id); How would i go about combining the two? I want -2 to be returned if...

Accessing the Custom Object Return type from ojdbc6 JDBC Thin Drivers

I'm writing some JDBC code which calls a Oracle 11g PL/SQL procdedure which has a Custom Object return type. I can get the code to call the procedure, but how do I access the returned Custom Object to obtain it's contained values?. An example of my code calling the procedure is below: PLSQL Code: Procedure GetDataSummary (p_my_key I...

Database Connection Problem with MS SQL Database: JDBC-ODBC Driver from JSP

I'm using Netbeans 6.8 to develop application using JSP. I'm able to work with it properly in my project guides system. But i'm unable to get the connection to database from my system. It shows error unable to connect. I have not changed any of the codes. How can I fix this error? ...

How can I identify columns when SELECTing from multiple tables with JDBC?

I have two tables that I join on the id-column, they look like: +-------+ | users | +----+--+---+ | id | name | +----+------+ +-------+ | posts | +-------+------+---------+ | id | user_id | message | +----+---------+---------+ And now I want to select all posts and include the username, with: SELECT * FROM posts, users WHERE user_id...

tomcat db2-jdbc datasource configure

Hi, i'm trying to configure a datasource of an db2 database in tomcat (using eclipse as IDE), but i cant solve the problem, Tomcat trow me the following exception: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(...

JPA vs. JDBC, stored procedures and Co. or How to convince old school programmer to try ORM?

This is something I deal periodically with, and first time it was me who needed conviction. Luckily, I just tried, made extra effort to learn and thanks to this book, Spring support, and Hibernate I won't start a project without considering JPA. But not everyone is willing to go extra mile that often (just in anything we deal with I gues...

Connecting to MS SQL Server 2005 via Hibernate

I have JRE 1.6 and am using the following hibernate.cfg.xml file. I am always getting "Cannot open connection" and "The port number 1433/DB is not valid." <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibern...

Java JDBC connections and Oracle

I have a scenario and the question follows Application server has two connections pools to DB. A and B A points to -> DatabaseA -> has 128 connections A has Stored Procedures which access tables residing in DatabaseB over the DB link B points to -> DatabaseB -> has 36 connections Now lets say that Java code calls Stored Proc in Dat...

[JSP, MySQL and Servlets] ResultSet loses first value

Code seems to work fine, but I noticed whenever I queried a string with only one result, it returned nothing. Somehow I am skipping the first result I think but have no idea why. else{ Conn con = null; try { con = new Conn(); } catch (Exception e) { e.printStackTrace(); } String sql = "SELECT productname, qu...

java - POST vs JDBC

OK so here's the code: import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class Main { public static void main(String[] args) { try { URL my_url = new URL("http://www.viralpatel.net/blogs/"); BufferedReader br = new BufferedReader(new InputStreamReader(my_url...

How to manage db connections on server?

I have a severe problem with my database connection in my web application. Since I use a single database connection for the whole application from singleton Database class, if i try concurrent db operations (two users) the database rollsback the transactions. This is my static method used: All threads/servlets call static Database.doSom...

How to convert String to Java.sql.date and Java.sql.time

Hello If I have a method like this: public static String convertDateTimeToString(DateTime dt) { return dt.getDate() + " " + dt.getTime(); } Which takes a Datetime object of my own which contains a Java.sql.date and a Java.sql.time, what is the best way of reversing the process so that I can substring a Java.sql.date and a Java.sq...

JDBC with MySQL

I'm working on getting my database to talk to my Java programs. What do I need to get started? Having already read through (and been thoroughly confused, something that does not happen often) with some other turorials I figured I'd best ask here. How do I import a jar file from the local directory? Can someone give me a quick and dirty ...