Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Default java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorre

    for(int x= 0; x < 20; x++) {
    for(int y = x + 1; y < 20; y++) {
    if(x != y)
    count++;

    System.out.println( count+") "+Combinedrule[x] + " " + Combinedrule[y]);
    String g=Combinedrule[x];
    String h=Combinedrule[y];
    sql[1]=" select confidence from cpm1 where conbinedrule=Combinedrule[x] ";
    sql[2]="select confidence from cpm1 where conbinedrule='h'";

    Error:May i know what i need to change in the sql command
    rs1=st1.executeQuery(sql[1]);
    rs2=st1.executeQuery(sql[2]);

    while(rs1.next())
    {
    con1[i]=rs1.getFloat(1);
    con2[i]=rs2.getFloat(1);
    System.out.println(con1[i]);
    System.out.println(con1[i]);
    System.out.println("*********************");

    }}}
    Last edited by nandhinianand; 09-27-2011 at 11:04 AM.

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    What's the full exception, with stack trace, you are getting.
    Highlight the line where the exception is thrown, and please use code tags when posting code.

  3. #3
    Thiruppathi is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    Hi

    Change the line with the text highlighted in green color

    sql[1]=" select confidence from cpm1 where conbinedrule='"+g+"'";
    sql[2]="select confidence from cpm1 where conbinedrule='"+h+"'";
    Last edited by Thiruppathi; 09-27-2011 at 01:37 PM.

  4. #4
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Smile Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    Could you please correct the java.sql.SQLException?
    public class CustomerTable1ISnull extends javax.swing.JFrame {
    public CustomerTable1ISnull(String st) {
    //initComponents();
    String Table=st;
    System.out.println("Table="+Table);
    ResultSet rs = stmt.executeQuery("Select * from '"+Table+"'where p1 is null or p2 is null or p3 is null or p4 is null or p5 is null");
    }


    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new CustomerTable1ISnull("str1");
    }
    });
    }
    Output:

    Table=Customer
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'Customer'.

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    Check in the MS SQL documentation whether putting ' around the table name is a valid thing to do. It isn't in MySql which expects backticks like `Customer`.

  6. #6
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Default Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    Select * from customer where p1 is null or p2 is null or p3 is null or p4 is null or p5 is null
    This query is successfully executed in the SQL Query Analyzer.
    Thanking you,
    With Regards,
    Nandhini

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Inc

    You're welcome.

Similar Threads

  1. Replies: 5
    Last Post: 09-11-2011, 05:13 AM
  2. Replies: 3
    Last Post: 08-15-2011, 10:16 AM
  3. Replies: 2
    Last Post: 08-11-2011, 02:41 PM
  4. Replies: 1
    Last Post: 08-06-2007, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •