jdbc

how to get mysql query result as xml?

I recall reading about XML support from MySql. Does anyone know how to get XML without writing code? My client-protocol expects XML and I have a data source that I can access from a web app (JSP using JDBC). ...

What's the cause of (and treatment for) this java MySQL exception?

I'm getting the following exception when executing the first preparedstatement after a period of inactivity: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 2,855,054 milliseconds ago. The last packet sent successfully to the server was 123 ...

Any gotchas in migrating database connectivity to DataSource?

Looking at some old application code which uses explicit driver loading as Class.forName(...).newInstance I have been told to change this to use the Java 1.4.2 mechanism to establish a database connection using ContextLookup, and DataSource. Are there any gotchas I should be aware of? ...

OracleDataSource connection caching - restarting connections?

Hello, Is it possible to set the Oracle connection cache to restart cached connections after a period of time? ...

ResultSet in JTable

How display ResultSet in JTable. i using this code /*String [] record= new String[ColCount]; for (i=0; i<ColCount; i++) { record[i]=rset1.getString(i+1); } cell[i] = rset1.getString("loginname"); cell[i] = rset1.getString( "role"); System.out.println(cell[i][0]); //ItemGroup = rset1.getString( "Status"); } System.out.println(...

alias all column in a query with a prefix

it's possible to alias all column with a prefix, in a select? I have a group of tables in an Oracle db that I need to join together, and most of them have the same column names. I would like to have something like select MAGIC_ADD_PREFIX("PREFIX", *) from TABLE and have a result like +---------+----------+----------+ |PREFIX_ID|PREFI...

Oracle JDBC connection exception in Solaris but not Windows?

I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It works just fine on my Windows XP machine. However, when running the same code on a Solaris machine, I get the following exception. Both machines can reach the database machine on the network. I have included the Oracle trace logs. Mar 2...

OSGI & Apache Commons-DBCP Classloading Issue

I inherited some code that is using the Apache commons-dbcp Connection pools in an OSGi bundle. This code works fine with Eclipse/Equinox OSGi version 3.4.3 (R34x_v20081215), commons-dbcp 1.2.2 and the postgres jdbc3 8.3.603 bundles from springsource.org. I wanted to modernize, maybe this was my first mistake! When I use the new versio...

JDBC resultset close

I am doing profiling of my Java application and found some interesting statistics for a jdbc PreparedStatement call: Given below is the environment details: Database: Sybase SQL Anywhere 10.0.1 Driver: com.sybase.jdbc3.jdbc.SybDriver connection pool: c3p0 JRE: 1.6.0_05 The code in question is given below: try { ps = conn.prepareSt...

DAO design pattern and using it across multiple tables

I'm looking for feedback on the Data Access Object design pattern and using it when you have to access data across multiple tables. It seems like that pattern, which has a DAO for each table along with a Data Transfer Object (DTO) that represents a single row, isn't too useful for when dealing with data from multiple tables. I was thinki...

DB.Null equivalent in JDBC

Is there an equivalent of (ADO.NET) DB.Null in JDBC? Or do I simply pass null in the parameter? Particularly in the context of Mysql? ...

CLASSPATH on Mac, and how does Mac look for mysql-connector-java-bin.jar

Is there a default classpath on Mac OS X 10.6? When I echo $CLASSPATH, nothing would show up. In my .profile, I only see PATH variable being set. My problem is that My servlet cant seem to find a suitable driver to connect to the mysql server. I use Eclipse, with Glassfish v3 and MAMP for MYSQL server. ...

stored procedures, error #1312, CLIENT_MULTI_RESULTS flag

i am writing stored procedures in MySQL that return values; CREATE PROCEDURE getCustomerById (id int) BEGIN SELECT * FROM customer WHERE customer.id = id; END; and i get the error that the results cannot be shown in the given context. after some googling, i think that i need to set the flag "CLIENT_MULTI_RESULTS" - i am conne...

How do I lookup a JNDI Datasource from outside a web container?

I have the following environment set up: Java 1.5 Sun Application Server 8.2 Oracle 10 XE Struts 2 Hibernate I'm interested to know how I can write code for a Java client (i.e. outside of a web application) that can reference the JNDI datasource provided by the application server. The ports for the Sun Application Server are all at ...

JDBC connectivity issue

I'm using the NetBeans IDE(6.8). I have a DB class : package garits; import java.io.Serializable; import java.sql.*; import java.util.Properties; public class DB implements Serializable{ private static final long serialVersionUID = 1L; String dbURL = "jdbc:mysql:///team_project"; String user = "root"; String pwd = "arsenal"; ...

how to identify wather execution of updatequery made changes or not in oracle database

hello friends i am using oracle as backhand and jsp servlet as frunthand i am executing update query and i want to identify wather update query has made updation in database or not. i am using executeUpdate() it is executing but it results 0 when update query fail to execute and 1 when execution is done but it does not identify wather da...

ClassNotFoundException when connecting to Mysql with JDBC

I'm getting the following error when I try to run a simple Java JDBC program at the command line: Exception in thread "main" java.lang.NoClassDefFoundError: LoadDriver/java Caused by: java.lang.ClassNotFoundException: LoadDriver.java at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged...

Reading ResultSet from multiple threads

Hello, In the database, I have a definition table that is read from the application once upon starting. This definition table rarely changes, so it makes sense to read it once and restart the application every time it changes. However, after the table is read (put into a ResultSet), it will be read by multiple handlers running in their...

String to Integer with JDBC /ODBC sql .

I am facing severe problem with JDBC ,converting string to integer. String query = "Select F2, F3, F4 from myTable ORDER BY {fn CONVERT(INT,F4)}" ; error: Syntax error in ORDER By clause; ...

Making serach on database and Listing results with Hibernate in Java

I am developing swing based application with hibernate in java . And ı want to make search on database , and listing result... Before ı used to JDBC and ResultSetTableModel , and my before code is here : try{ Class.forName("*****************").newInstance(); Connection baglan=(Connection) DriverManager.getConnection("*******...