problem with executeQuery statement

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

[344 byte] By [Java@2007a] at [2007-11-27 6:33:07]
# 1
> so I gave it in multiline How?> its showing errorThere are countless different kinds of "error" and you haven't even taken the effort to post the exact error message here? You, as developer, should know that better.
BalusCa at 2007-7-12 17:58:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

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");

Statementstmt = connection.createStatement();

ResultSet rs = stmt.executeQuery("SELECT TEMP1.EMPLOYEE_NAMEEMPLOYEE_NAME1,"+

"TEMP1.LINELINE1,"+

"TEMP1.COURSE_NAMECOURSE_NAME1,"+

"TEMP1.T_DATETEMP_DATE,"+

"TEMP1.SCORETHEORY_SCORE,"+

"TEMP1.RESULTTHEORY_RESULT,"+

"TEMP1.FLAGTHEORY_FLAG,"+

"TEMP1.TH_DATETHEORY_DATE,"+

"PRACTICAL.SCOREPRACTICAL_SCORE,"+

"PRACTICAL.RESULTPRACTICAL_RESULT,"+

"PRACTICAL.FLAGPRACTICAL_FLAG,"+

"PRACTICAL.P_DATEPRACTICAL_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"

Java@2007a at 2007-7-12 17:58:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
This exception simply means that your SQL syntax is bad. Print the statement to the console and re-read it. Big chance that you're missing some spaces.
BalusCa at 2007-7-12 17:58:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
Is there is any other way other than, printing and re-reading from consoleQuery is working fine.....Message was edited by: Java@2007
Java@2007a at 2007-7-12 17:58:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> Is there is any other way other than,

> printing and re-reading from console

Yes. Not printing it and reading it directly in the code. But you, as inexperienced developer, should likely find it more easy to read it in one line, because you can more quickly locate missing spaces then.

BalusCa at 2007-7-12 17:58:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...