I've got a rather large program that interacts with a MySQL database. I recently changed the structure of the database considerably, but I thought I had made all of the necessary changes to my program to compensate for those database changes, but clearly I haven't.
I just recently several error messages, the first of which is this:
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
Strangely, though, it doesn't give tell me in which file this error came from (as a typical stacktrace would), let alone on which line number. How can I figure out from where this is coming?
I have a lot of calls to the database in this program, most of which deal with a Timestamp column. And I'm afraid that, while I have been using Eclipse for months now, I still have yet to use its Debug perspective. How can I use that?
Related
So here is the problem. I am scraping some data with java and eventually i place that java into postgres database. When i run Java program, i get error ERROR: relation "table name" does not exist but when i personally write that same query in PGAdmin III, it works fine. I googled it and it's not about caps letters that most people have problems with. Here is a screenshot:
My first thought was that you were using double quotes for values, but then I looked again and realized you were assembling a query using string concatenation.
DON'T DO THAT. In addition to making these problems impossible to debug you open yourself up to sql injection.
In debugging something like this, you should first port to use placeholder syntax (which PostgreSQL's JDBC driver supports) and then, if that doesn't work, then post the server logs.
I have this java program that reads values from a database, and uses those values in each table for creating a schedule.
I do not have a server accessible, so the database will have to be moved around from computer to computer when the program is moved. It will have about 200 tables, each one with a time, number, title, and description.
I have tried using Microsoft Access, but Java 8 just changed some setting so that the program cannot link the Access database, even though there used to be a simple way to do this.
I know about Java DB, but to my knowledge it needs a server to host the database on, same with SQL, and I do not have one to use.
My question is, which program can I use to create a client-side database that can be linked with a java program, without breaking off an arm and a leg.
Thank You for any suggestions.
I have a simple test case producing a sure ArrayOutOfBoundException in jzlib
1.0.7 depending on the data subsequently written to one and the same instance
of ZOutputStream.
Stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 587
at com.jcraft.jzlib.Tree.d_code(Tree.java:149)
at com.jcraft.jzlib.Deflate.compress_block(Deflate.java:691)
at com.jcraft.jzlib.Deflate._tr_flush_block(Deflate.java:897)
at com.jcraft.jzlib.Deflate.flush_block_only(Deflate.java:772)
at com.jcraft.jzlib.Deflate.deflate_slow(Deflate.java:1195)
at com.jcraft.jzlib.Deflate.deflate(Deflate.java:1567)
at com.jcraft.jzlib.ZStream.deflate(ZStream.java:133)
at com.jcraft.jzlib.ZOutputStream.write(ZOutputStream.java:102)
at com.jcraft.jzlib.JZLibTestCase.main(JZLibTestCase.java:51)
at JZLibTestCase.main(JZLibTestCase.java:28)
The problem occurs very rarely and depends on the data subsequentially
written to an open ZOutputStream from jzlib.
Do you have a hint how to fix this? Have you ever heard of this?
Near as I can tell you might've found a bug with JZlib. While searching around I came across other places that have your post with attached source and data files. It does not appear that you're doing anything wrong. You should be able to stream any sequence of bytes to ZOutputStream.
Is there a particular reason you're using JZlib? The two main reasons I understand to use it are support for Z_PARTIAL_FLUSH mode and licensing. If you don't need that flush mode and you're using the Oracle JVM, you should be just fine with the included DeflaterOutputStream. Substituting it in your code for ZOuputStream works without an exception.
I haven't found a concrete reason for using jzlib asking my co-workers, but for sure there has been a bug using java.util.zip somewhen in JRE 1.4 on multi-processor systems, although no one has been able to tell me concretely which one. From that time on we have been using jzlib, which has worked good for many years. Most probably it is already fixed. Nevertheless, using java.util.zip works with my simple test data in the same manner jzlib failed with, that's true.
I am using hibernate in my java dynamic project and since last week I am getting one exception called "No row with the given identifier exist[#entity(0)]. I found same problem asked earlier and I did same as suggested but problem persisted. I tried using "not-found=ignore" case as well but it doesn't work. Even the project is working fine # Production but here # development is quite disturbing. Please help me.
Maybe this can help explain it.
Just a suggestion: whenever I get an error message of any kind, I immediately cut & paste it into a Google search to see what comes back. It's highly unlikely that I'm the first person to encounter a problem.
Problem solved: Thanks guys, see my answer below.
I have a website running in Tomcat 5.5 hooked up to a MySQL5 database using Hibernate3.
One record simply refuses to keep any changes performed on it. If I change the record programmatically, the values revert back to what they were previously.
If I manually modify the record in the database, the values will revert (seemingly once the webapp accesses them).
I have tried stopping Tomcat and changing the values manually then starting Tomcat again. Checking the database, the values remain changed after Tomcat has started the webapp but will revert back again once I load the site.
I have also tried deleting the Tomcat work folder for the webapp and the .ser cache file.
I have also checked the code for the values that are being reverted to and cannot find them.
I have only noticed it on this one particular record.
Edit: I've just had a look at the SQL output from Hibernate using hibernate.show_sql=true. There is an update query logged for the table my row is in. Does anyone know how to resolve the ? for the columns to actual values?
You could temporarily enable the mysql query logging and see exactly what sql statement altered the value. Since you say it changes immediately after the server starts you should be able to figure out the statement pretty quickly.
http://dev.mysql.com/doc/refman/5.0/en/query-log.html
To answer your question:
Does anyone know how to resolve the ?
for the columns to actual values?
You can do this with p6spy. Instructions for how to set this up in a Spring app are available here.
However, I think there's a mistake in these instructions, the file they refer to as p6spy.log should actually be name p6spy.properties.
It's getting close to halloween, so you have to expect this sort of thing (plus it was just a full moon), but I'd keep looking for the culprit in the web application ... it HAS to be there. A couple values I'd immediately search for in the webapp source code:
The id of the record being changed.
The value that's being written into
the record.
Good luck ... these can be real bears to find!
This smells a little like a test-case firing on start up that modifies the row to what it expects it to be before testing.
Add a trigger BEFORE UPDATE, check row id, raise an SQL error if it matches your magic row.
Then check the generated stacktrace, walk the code and locate the piece that updates the row.
Thanks to everyone for the help. All of the suggestions came in handy for tracking it down.
I've managed to find out what was causing it. Bad database design, multiple data models and Hibernate makes for some nasty stuff. Another table had the value stored and that class was extending a base class with the same value.
Time to look at doing some normalisation.