Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic