Given this java code...
PreparedStatement s = prepare("SELECT ...")
ResultSet r = s.executeQuery()
r.next()
s = prepare("UPDATE ...")
s.setInt(1, r.getInt(3))
s.setInt(2, r.getInt(1))
s.executeUpdate()
s = prepare("UPDATE ...")
s.setInt(1, r.getInt(3))
s.setInt(2, r.getInt(2))
s.executeUpdate()
It seems to me that MySQL JDBC would hav...
Imagine you have the following table (note: this is a contrived/simplified example):
CREATE TABLE foo (
book_id number,
page number,
-- [a bunch of other columns describing a single page in a book]
);
ALTER TABLE foo
ADD (CONSTRAINT foo_pk PRIMARY KEY(book_id, page));
While (book_id, page) pairs are unique, the same page nu...
Dear All,
I just start reading Sun's JDBC tutorial. I installed MySQL Connector/J and was just skimming through its menu, then came across this statement:
"Although JDBC is useful by itself, we would hope that if you are not familiar with JDBC that after reading the first few sections of this
manual, that you would avoid using naked JD...
I am getting an exception:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
I found a list of JDBC Data type here Apache DB Project . How do I find out "-9" maps to one of the data types listed? From googling, people seem to say -9 represents nvarchar, but is there an authoritative source?
...
Is it possible to run a java jar file from within an Oracle (10g) database? More specifically, I am looking to schedule an oracle job using
dbms_scheduler.create_job(...)
When run, the job would call a Java Application that performs a process involving talking to another application via HTTP, some business logic, then executing a Sto...
I am trying to connect to a MySQL database using Java. I want to grab all the entries for two row from two rows in a database and put them into the class ExpertScore. I then want to put the newly created ExpertScore objects into an array of ExpertScore objects. After this I want to run them through a method that takes an array of ExpertS...
Essentially, I have a methods that manipulates data taken from a table to create a new object "ZExpert." ZExpert has parameters int id, int domain, and double ZExpert. I have added a column to the table I took the data from called "Z_Expert_Score."
I want to put the double ZExpert score from the object in the column Z_Expert_Score, in ...
I am trying to use H2 to connect to a database in Java (using Eclipse as the IDE). The sample does (below) throws a ClassNotFoundException. The thing is, I did add the h2 jar file to the system CLASSPATH. I have even checked it's there several times via 'printenv' in the console. Am I omitting a step?
CODE:
import java.sql.*;
public c...
I'd like to pass out a result set from a function that executes a query and closes the connection.
But the ResultSet gets invalidated as soon as its parent Connection is closed and throws "java.sql.SQLException: Operation not allowed after ResultSet closed". How to avoid this?
...
Resultset rs=stmt.executeQuery("select count(*) from feedsca group by score order by score");
Using the above java code above, am retrieving the counts of rows from the table named feedsCA.
While trying to retrieving the counts using rs.getInt(1),rs.getInt(2),rs.getInt(3), I end with an error saying as below,
Exception in thread "mai...
I have a Jruby app that spins up several background Java threads that share an ActiveRecord (2.3.5) connection. If they sleep for some time and then try to do something database related, the first queries never execute. I believe this is because the connections are stale, but the code itself doesn't throw any errors.
I've tried doing ...
Hi, I'm testing rollback in java using JDBC (with mysql), but the code below is not working. The code is behaving as if I called commit() instead of rollback(). Can somebody tell me where I'm going wrong?
Connection conn=null;
try
{
conn = SqlConnectionHandler.getSqlConnection();
conn.setAutoCommit(false);
}
...
What are the analogies between the objects found in JDBC and the ones found in ADO.Net?
I know the object model in JDBC and ADO.Net are not exactly the same, but I think some analogies can be found among them (and key differences worth stating).
That would be useful for those who knows one API and wants to learn the other, serving as a...
Hello everyone,
I am currently trying to code our existing desktop application in JSP.
To be able to maintain sustainability, have visual effects and get functionality, I have decided to use JQuery.
After starting to code a month ago, we now realized that these pages are bringing a heavy usage of libraries (JQuery and JQueryUI librar...
I have a servlet that performs an ANT build, I've attached a org.apache.tools.ant.listener.Log4jListener as you can see below and at the end of the build the org.apache.tools.ant.listener.Log4jListener is not released, the only way I've found around this is to restart Tomcat. If I don't restart Tomcat the next time I try to run the buil...
Could somebody point me at or post an example of configuring a data source for JBoss 5.1.0.GA?
I am getting the following error when I try to hook up a data source to my web application in JBoss 5.1.0.GA using JNDI.
startup failed due to previous errors java.lang.RuntimeException: mapped-name is required for jdbc/jos of deployment j...
Hi,
I'm getting the following exception in my log when I try to perform an XA transaction:
javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc_SQLServerException: failed to create the XA control connection. Error: "The EXECUTE permission was denied on the object 'xp_sqljdbc_xa_init_ex', database 'master' schema 'dbo'
I f...
I'm trying to get JDBC transaction rollback when using Spring-test without success. When I run the following the SQL update is always committed.
package my.dao.impl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;...
When using Tomcat with MySQL, what is the relationship between poolPreparedStatements setting in Tomcat DataSource configuration (I believe coming from DBCP) and Connector/J cachePrepStmts setting? What's the optimal configuration?
...
com.microsoft.sqlserver.jdbc.SQLServerException: The system is out of memory. Use server side cursors for large result sets:Java heap space. Result set size:280,236,031. JVM total memory size:423,297,024.
I am trying to fetch a big data set from SQL and I get following error. Let me know if anyone have seen something similar and wi...