aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can someone debug this code, I Watch "Can someone debug this code, I New topic
Author

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());

oStmt.executeUpdate();
} 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
HI,
Is the date passed in as a String?
>> oStmt.setString(2, oV.getPostDate());
Might be that.
Bye,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

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?
 
 
subject: Can someone debug this code, I'm stumped...