SQL Exception: with different data types
I am getting the following error.
SQL Exception: Columns of type'DATE' cannot hold values of type'INTEGER'.
Here's the code I used to create my table.
String createBillsTable ="create table bills(billName varchar(50), dueDate date, lastPaidDate date, amountDue double, lastPaidAmount double)";
Here's the code used to insert the data.
publicvoid insertBillData(){
try{
String billName ="ElectricBill";
Date dueDate =new Date(07/15/2006);
double amountDue = 50.55;
Date lastPaidDate =new Date(06/15/2006);
double lastPaidAmount = 60.25;
String insertStatement ="insert into bills values ('" + billName +"', '" + dueDate +"', " + lastPaidDate +", " + amountDue +", " + lastPaidAmount +")";
establishConnection();
statement.execute(insertStatement);
closeConnection();
shutDownDerby();
}catch (Throwable e){
System.out.println("exception thrown:");
if (einstanceof SQLException){
printSQLError((SQLException) e);
}
else{
e.printStackTrace();
}
}
}
If I create my table with only one Date and then try and insert just one Date it works fine. I've tried inserting each of my two different dates seperately one at a time at it works fine. I've used sysouts and getClass() to verify that both my dates are in fact SQL dates before inserting and they are.
I'm doing this just as an exercise to teach myself JDBC and using Derby as my DB. SO far everything has been great until I came across this. Now I'm a bit stumped. Am I missing something obvious?
I apologize if this is just some stupid SQL question, and realize it really doesn't have much to do with Connectivity but was hoping someone could maybe spot something I'm over looking. I can post more code if needed but thought this was all that was relevent.
Message was edited by:
kefgolfs

