jdbc

JDBC Connect and Disconnect: Am i doing it right?

Hi I just faced the following exception : Exception Occured while Connecting : com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket. This is usually caused by a limit on the number of sockets imposed by the operating syst...

sqlite database connection/locking question

Folks I am implementing a file based queue (see my earlier question) using sqlite. I have the following threads running in background: thread-1 to empty out a memory structure into the "queue" table (an insert into "queue" table). thread-1 to read and "process" the "queue" table runs every 5 to 10 seconds thread-3 - runs very infrequen...

Best book to learn JSP fast and quick

Please suggest me a good book to learn JSP and JDBC basics fast and quick. Its like i have 3-4 days to go through the basics of JSP and JDBC. I have never used them before, however i have worked on java a lot. Currently, I am programming on ROR. So, a nice book to get me through the basic stuff of JSP and JDBC ...

Hibernate 3.5.1, JPA2.0 & MySQL - Alternate behaviour within 2 diff dbs / same server

I am running a MySQL 5.1 server and Hibernate 3.5.1 / JPA2 for ORM. Everthing seems fine until I drop some tables manually. From then on, unit tests fail with Hibernate no longer creating certain tables. Changing the jdbc url from url=jdbc:mysql://localhost:3306/dbjava?createDatabaseIfNotExist=true to url=jdbc:mysql://localhost:3306...

How to use mysql IN comparison function with JDBC

This seems simple, but it is impossible to search the web for... I have a legacy application that uses JDBC directly with no frameworks, and I'm having to add some new features. I'm having issues finding out how to use the IN() function via JDBC. I would like to have a query like the following SELECT * from animals WHERE animal_name ...

A very very strange error ClassCastException. PreparedStatement's setInt method.

Can anybody tell me why is this method not working? String strQuery = "Insert Into cust_subs (CustomerId,SubscriptionId) Values (?,?)"; PreparedStatement objPreparedStatement = Utils.getPreparedStatement(objConnection, strQuery); objPreparedStatement.setInt(2, currentSubscriptions.get(0) ); where currentSubscriptions is: List<Integer...

Slow XML response in Java Servlet with MySQL connector

Hi, I created a Java Servlet that get query result from mySQL database and print it in XML format. the problem is that it takes a very long time, something about three minutes to print the xml result while in my PHP script it takes 5 seconds. My Servlet relevant function is: ( run a query and return the xml in a String variable, then, p...

JDBC (mysql) saves queries in heap memory

Hi, I am trying to run Hibernate Search on database on a table with 12,500,000 records. On startup, Hibernate Search queries the database to obtain the schema information. The problem is that I get OutOfMemory: heap size exception. I read around, and found out that JDBC connector of MySQL puts queries on JAVA heap memory and it's a b...

Java: MySQL query. Get generated ID.

I have a table that contains a column called 'id' that is an INT that auto increments and is set to be the primary key. I need to get the value of the generated ID after the query is run. I have the following: String sql = "INSERT..."; Statement statement = sqlConnection.createStatement(); int result = statement.executeUpdate(sql, ...

JDBC Embedded Firebird: operating system directive failed

I'm writing a small java program that can read a .GDB file using the embedded Firebird server (libfbembed.so) on linux. I have all my paths correct: my classpath provides the Firebird classes, and my java library path provides the jaybird library. My connection string is: private String connectionString = "jdbc:firebirdsql:embedded:/...

accessing Object[] values in Java

Hello, Regarding to this image: link text I have an object, 'rezultat', which has getters and setters. I wanna set for 'cli' attribute ( rezultat.setCli(String .....) ), and as string parameter it should be that m_objArray[0], so 'ADSL22675....' from that image. Expanding m_objArray there are 19 attributes i need to set for the 'rezult...

Spring Jdbc atomicity with alter table

I'm trying to write an equivalent of Rails data model evolution/rollback mechanism using Spring Jdbc. Spring Jdbc transactionnal insert/replace works very well (DataSourceTransactionManager with PROPAGATION_REQUIRED under InnoDB mysql 5) : // Transaction begins getJdbcTemplate().execute("replace into aTable ..."); getJdbcTemplate().exe...

mySQL jar name and location

I wanted to know, What jars do I need to have to connect to MySQL, and Where can I download it? I googled it but there are so many of'em. Can somebody tell me what class DO I need to use.? Thanks ...

Spring Like clause

I am trying to use a MapSqlParameterSource to create a query using a Like clause. The code is something like this. The function containing it receives nameParam: String namecount = "SELECT count(*) FROM People WHERE LOWER(NAME) LIKE :pname "; String finalName= "'%" +nameParam.toLowerCase().trim() + "%'"; MapSqlParameterSource namedP...

How to pass an array object from jdbc code

Hi, I have a stored procedure get_data(estargs set(char(1000) not null)) in the informix 11.5 database. I have to use this stored procedure in order to get a value from the database. I tried using this way but it fails: conn = dataSource.getConnection(); String [] arrayObj={"and code = 'Value1'","and lmt= 10000.000"}; ...

How to archive a distributed (database) transaction between a java and c++ application?

I'd like to know how to archive a distributed (database) transaction between a java and a c++ application. Are there some frameworks/jdbc extensions to do this? What pitfalls may arise? The solution may be oracle-specific, but a more general approach (at least on the java side) would be prefered, if equal. ...

Need help on learning java frameworks quickly

I wrote a piece of java code using threads, JDBC, Java Mail API etc. without using any of the frameworks (read Spring). I am frankly not too comfortable learning them first (lots of terminologies to remember!) and use them. So, please suggest me some ways to refine my existing code incorporating few of these framework concepts applicable...

Storing a JDBC Connection in HttpSession

I've recently inherited some code, within which I've found a JDBC connection being initialized in a filter and added the the HttpSession for each user. That connection is then reused throughout various portions of the web application for the user. This immediately stood out to me as a code smell. I'd like to go back to the developer w...

Are there any JDBC implementations for NoSql databases?

I just wonder if there are any JDBC implementations (in some extent, as much as possible) for any NoSql DB (opensource or proprietary)? How do you think, is it possible that this implementation will show as good performance as raw API of correspondent NoSql DB? Which parts cannot be implemented (transactions? CallableStatements? etc)? ...

search for a string in a blob data type

Is there a mechanism to search for a string within a blob data type. I tried converting the blob to xml data type - however, i get a hex string output. Anyway to convert the hex string into meaningful ascii? I use JDBC 3.0 - so resultSet.getSQLXML().getString() method is not an option. ...