Problem with executeQuery statement

Advertisement
Hi all,
I have one connectivity program, in which in the code shown below,
ResultSet rs = stmt.executeQuery(" ");within double quotes I gave a sql query, which is very big, so I gave it in multiline but it is not accepting. its showing error...please help me in this...
Thanks in advance
Advertisement

Replay

Like this I gave,
public static void certificationDetails()               //User Defined Method for creating a table, by getting details  from  database
                    System.out.println("inside main");
                    Connection connection = null;
                    try
                         // Load the JDBC driver
                         String driverName = "org.gjt.mm.mysql.Driver";               // MySQL MM JDBC driver
                         Class.forName(driverName);
                         System.out.println("driver loaded");
                         // Create a connection to the database
                         String serverName = "localhost";
                         String mydatabase = "dltrg";
                         String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
                         String username = "root";
                         String password = "";
                         connection = DriverManager.getConnection(url, username, password);
                         System.out.println("Connection Successful");
                         Statement     stmt = connection.createStatement();
                         ResultSet rs = stmt.executeQuery("SELECT  TEMP1.EMPLOYEE_NAME     EMPLOYEE_NAME1,"+
                  "TEMP1.LINE                    LINE1,"+
                  "TEMP1.COURSE_NAME     COURSE_NAME1,"+
                  "TEMP1.T_DATE               TEMP_DATE,"+
                  "TEMP1.SCORE               THEORY_SCORE,"+
                  "TEMP1.RESULT               THEORY_RESULT,"+
                  "TEMP1.FLAG               THEORY_FLAG,"+
                  "TEMP1.TH_DATE               THEORY_DATE,"+
                  "PRACTICAL.SCORE          PRACTICAL_SCORE,"+
                  "PRACTICAL.RESULT          PRACTICAL_RESULT,"+
                  "PRACTICAL.FLAG          PRACTICAL_FLAG,"+
                  "PRACTICAL.P_DATE          PRACTICAL_DATE"+
"FROM" +
             "( SELECT TEMP.EMPLOYEE_NAME, TEMP.LINE, TEMP.COURSE_NAME, TEMP.DATE T_DATE, TEMP.C_ID, TEMP.E_ID,THEORY.SCORE, THEORY.RESULT, THEORY.FLAG, THEORY.DATE TH_DATE "+
                "FROM"+
                            "( SELECT T.EMPLOYEE_NAME,"+
                                               "T.LINE,"+
                                               "T.COURSE_NAME,"+
                                               "T.DATE,"+
                                               "T.C_ID,"+
                                               "T.E_ID"+
                               "FROM TEMPORARY_MASTER T"+
                            ")  TEMP"+
                            "LEFT OUTER JOIN"+
                            "( SELECT T1.SCORE,"+
                                               "T1.RESULT,"+
                                               "T1.DATE,"+
                                               "T1.FLAG,"+
                                               "T1.C_ID,"+
                                               "T1.E_ID,"+
                                               "T1.LINE"+
                              "FROM THEORY_MASTER T1"+
                              "WHERE FLAG = 'Test'"+
                           ") THEORY"+
                           "ON ( TEMP.C_ID = THEORY.C_ID AND TEMP.E_ID = THEORY.E_ID AND TEMP.LINE = THEORY.LINE )"+
             ") TEMP1"+
             "LEFT OUTER JOIN"+
             "( SELECT T2.E_ID,"+
                                "T2.C_ID,"+
                                "T2.LINE,"+
                                "T2.DATE P_DATE,"+
                                "T2.SCORE,"+
                                "T2.RESULT,"+
                                "T2.FLAG"+
               "FROM PRACTICAL_MASTER T2"+
               "WHERE FLAG = 'Test'"+
            ") PRACTICAL"+
            "ON ( TEMP1.C_ID = PRACTICAL.C_ID AND TEMP1.E_ID = PRACTICAL.E_ID AND TEMP1.LINE = PRACTICAL.LINE )");it is showing SQL exception like......
java.sql.SQLException: Syntax error or access violation message from server:
"You have an error in your SQL syntax;
check the manual that corresponds to your My SQL server version for the right syntax to use near
'( SELECT TEMP.EMPLOYEE_NAME, TEMP.LINE, TEMP.COURSE_NAME, TEMP.DATE T_DATE, TEMP' at line 1"