Anand,

Yes it worked ; Thanks a lot

Kat



On Sun, Nov 1, 2009 at 6:59 AM, kat Owen <[email protected]> wrote:

> That's is true. I did not think about it. Thank you very much!! appreciate
> it. I am going to try it out now.
>
> Kat.
>
>   On Sat, Oct 31, 2009 at 9:30 PM, Anand <[email protected]> wrote:
>
>>  hi,
>>
>> TestCaseId1, TestCaseName1, TestResults1 should not be in string quotes
>>
>> String table = "INSERT INTO JAPTestResults(TestCaseId, TestCaseName,
>> TestResults) VALUES ( "+TestCaseId1+",' "+ TestCaseName1+
>> " ',' "  + TestResults1 +" '  )";
>>
>> database always accept values in single quotes for string and direct
>> incase of integer.
>>
>> anand
>>
>>
>>
>>   On Sat, Oct 31, 2009 at 8:27 PM, kat Owen <[email protected]> wrote:
>>
>>>
>>>
>>> Hi all
>>>
>>> Thanks for all your help!!
>>>
>>> I need more help .
>>>
>>>
>>> Now I am able to conenct to the db and create a table and insert values ;
>>> But when I try to parameterize the values. I bump into some SQLException:
>>>
>>> The problem is in the following line : when I use values like 5,
>>> 'AddConn', 'Passed'  But when I parameterize them it throws this
>>> excepiton .
>>>
>>>
>>> String table = "INSERT INTO JAPTestResults(TestCaseId, TestCaseName,
>>> TestResults) VALUES (TestCaseId1, TestCaseName1, TestResults1)";
>>>
>>> //String table = "INSERT INTO JAPTestResults(TestCaseId, TestCaseName,
>>> TestResults) VALUES (5, 'AddConn', 'Passed')";
>>>
>>>
>>> *
>>>
>>> com.mysql.jdbc.exceptions.MySQLSyntaxErrorException
>>> *: Unknown column 'TestCaseId1' in 'field list'
>>>
>>> at com.mysql.jdbc.SQLError.createSQLException(
>>> *SQLError.java:936*)
>>>
>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(
>>> *MysqlIO.java:2985*)
>>>
>>> at com.mysql.jdbc.MysqlIO.sendCommand(
>>> *MysqlIO.java:1631*)
>>>
>>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
>>> *MysqlIO.java:1723*)
>>>
>>> at com.mysql.jdbc.Connection.execSQL(
>>> *Connection.java:3277*)
>>>
>>> at com.mysql.jdbc.Statement.executeUpdate(
>>> *Statement.java:1402*)
>>>
>>> at com.mysql.jdbc.Statement.executeUpdate(
>>> *Statement.java:1317*)
>>>
>>> at createTable2.insertResults(
>>> *createTable2.java:107*)
>>>
>>> at createTable2.main(
>>> *createTable2.java:161*)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> my main program :
>>>
>>>
>>> *
>>>
>>> public
>>> **static* *void* main(String args[])
>>>
>>> {
>>>
>>>  *int* testcaseId = 5;
>>>
>>> String TestCaseName =
>>> "AddConn";
>>>
>>> String TestCaseResults =
>>> "Passed";
>>>
>>> *try*
>>>
>>> {
>>>
>>> createTable2 abc =
>>> *new* createTable2();
>>>
>>>  //*abc*.createTab();
>>>
>>>   System.
>>> *out*.println(" before calling the methos" + testcaseId + TestCaseName +
>>> TestCaseResults );
>>>
>>> abc.insertResults(testcaseId, TestCaseName, TestCaseResults);
>>>
>>>  }
>>> *catch* (Exception e)
>>>
>>> {
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>>
>>> *
>>>
>>> public
>>> **void* insertResults(*int* testCaseId, String testCaseName, String
>>> testResults)
>>>
>>> {
>>>
>>> Connection connection =
>>> *null*;
>>>
>>> Statement statement =
>>> *null*;
>>>
>>> *int* TestCaseId1 = 0;
>>>
>>> String TestCaseName1 =
>>> "First";
>>>
>>> String TestResults1 =
>>> "PassedORFailed";
>>>
>>>  *try* {
>>>
>>>  System.
>>> *out*.println(" In the method first call" + testCaseId + testCaseName +
>>> testResults );
>>>
>>>  /* TestCaseId1 = testCaseId;
>>>
>>> TestCaseName1 = testCaseName;
>>>
>>> TestResults1 = testResults;*/
>>>
>>>  System.
>>> *out*.println("in the method second call " + TestCaseId1 + TestCaseName1
>>> + TestResults1 );
>>>
>>>  // load the driver class
>>>
>>> Class.*forName*(
>>> *DRIVER*);
>>>
>>> // establish the connection
>>>
>>> connection = DriverManager.*getConnection*(
>>> *DATABASE_URL*,"root","root");
>>>
>>>  statement= connection.createStatement();
>>>
>>> String table =
>>> "INSERT INTO JAPTestResults(TestCaseId, TestCaseName, TestResults) VALUES
>>> (TestCaseId1, TestCaseName1, TestResults1)";
>>>
>>> //String table = "INSERT INTO JAPTestResults(TestCaseId, TestCaseName,
>>> TestResults) VALUES (5, 'AddConn', 'Passed')";
>>>
>>> statement.executeUpdate(table);
>>>
>>> System.
>>> *out*.println("Table Insert process successfully!");
>>>
>>> //connection.prepareStatement("INSERT INTO JAPTestResults2 (id, data)
>>> VALUES (1,'ABA')");
>>>
>>> }
>>> *catch* (SQLException insert)
>>>
>>> {
>>>
>>> insert.printStackTrace();
>>>
>>> }
>>>
>>> *catch* (ClassNotFoundException classNotFound)
>>>
>>> {
>>>
>>> classNotFound.printStackTrace();
>>>
>>> }
>>>
>>> *finally*
>>>
>>> {
>>>
>>> *try* {
>>>
>>>  statement.close();
>>>
>>> connection.close();
>>>
>>> }
>>> *catch* (Exception e)
>>>
>>> {
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> >>>
>>>
>>
>>
>> --
>> Regards,
>>
>> AnAnD,
>> Software Engineer,
>> ZEDO AdServing
>>
>> .
>>
>
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to