wood burning stoves*
The moose likes JDBC and the fly likes Can someone debug this code, I'm stumped... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can someone debug this code, I Watch "Can someone debug this code, I New topic

Can someone debug this code, I'm stumped...

David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
This code executes without exception, but the record does not get inserted. The oV object is a validation bean I'm using and I've output the get... values and they are valid.
Also, the oManager.oCon is my connection pool manager and it is returning a valid connection object as I can navigate around using the same bean/connection and other queries work fine.
I'm using mySQL as DB. No issues there (other queries work fine).
Any ideas?
public void insertArticle(Validation oV) throws Exception {
PreparedStatement oStmt = null;
String SQL = "";

try {
SQL = "insert into LatestNews (Article, PostDate, NewsHeader) values (?, ?, ?)";

Debug = SQL;

oStmt = oManager.oCon.prepareStatement(SQL);

//oStmt.setInt(1, Integer.parseInt(oV.getUserID()));
oStmt.setString(1, oV.getArticle());
oStmt.setString(2, oV.getPostDate());
oStmt.setString(3, oV.getNewsHeader());

} catch (Exception e) {
throw new Exception("
" + oName + ": insertArticle(" + oV.getArticle() + ", " + oV.getPostDate() + ", " + oV.getNewsHeader() + "): " + e);
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Is the date passed in as a String?
>> oStmt.setString(2, oV.getPostDate());
Might be that.

Terry Doyle
Sun Certified Programmer for Java 2 Platform

Raising Flares debut album 'Ignition' out now


Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
I found the issue...It appears that I can only insert records if the date format is yyyy-mm-dd. If you pass a date into mySQL as mm/dd/yyyy, it doesn't insert the record and doesn't throw any exceptions...
Anyone else have this kinda issue?
I agree. Here's the link: http://aspose.com/file-tools
subject: Can someone debug this code, I'm stumped...
Similar Threads
how integrate MySQL and Tomcat
Retry Failed Insert Attempt?
BMP, Jboss, and mysql configuring
Help Needed: Stopping JBoss when the databse server is down
Insertion Values not get stored in sql server using stored procdure in struts2