what is wrong
i m getting this error
unclosed string literal
ResultSet result = stmt.executeQuery("SELECT cust_first_name,cust_last_name,...............
my statement is
ResultSet result = stmt.executeQuery("SELECT cust_first_name,cust_last_name,cust_address,cust_country,
cust_email FROMcustomer WHERE (cust_first_name = first_name
AND cust_last_name = last_name)");
what is wrong?
[468 byte] By [
anya_aaa] at [2007-11-27 3:42:58]

You have an unclosed String literal, just like the error says. You can't have line breaks in String literals. If you want to split it up onto multiple lines, you have to make two Strings and concatenate them together.
String s = "This is the first line" +
"and this is the second line.";
what is wrong now
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.Cookie;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
error is
.\Oracle.java:6: ';' expected
^
: cannot find symbol
symbol : class jdbc
location: class Oracle
DriverManager.registerDriver(new Oracle.jdbc.driver.OracleDriver());
what is wrong now?
> what is wrong now
> > import javax.servlet.*;
> import javax.servlet.http.*;
> import javax.servlet.http.Cookie;
> import java.util.*;
> import java.io.*;
> import java.sql.*;
> import javax.sql.*;
>
>
>
>
> error is
> .\Oracle.java:6: ';' expected
> ^
> : cannot find symbol
> symbol : class jdbc
> location: class Oracle
> DriverManager.registerDriver(new
> (new Oracle.jdbc.driver.OracleDriver());
>
>
> what is wrong now?
I am just going to venture a guess here...
But I assume that where you say (new Oracle.jdbc.driver.OracleDriver()); that the first Oracle should not be capitalized.
Eg.
new oracle.jdbc.driver.OracleDriver()
why on earth are you registering that driver by hand? is that really necessary?
thx i solved that myself and then my classpath was alo not set properly.
now another error
String queryinsert = "INSERT INTO" + customer (cust_id,cust_first_name,cust_last_name,cust_address, cust_country, cust_email) +" VALUES"+"('" + custId+ "',"
+ firstname + "',"
+ lasttname + "',"
+ address + "',"
+ country + "',"
+ email + "')";
it says ,it cannot recognize cust_id
the cust_id is a field in oracle table,i ve checked the field name is correct.
cust_id is a variable name in your code. If you want to put the String "cust_id" into your String, then you have to put it in quotes. If you want to insert the value of a String variable there, then you have to make sure that cust_id variable is defined in the scope of that line.
thank you
plz help me with this syntax also
String queryinsert = "INSERT INTO" + customer ("cust_id","cust_first_name","cust_last_name","cust_address", "cust_country", "cust_email") +" VALUES"+"('" + custId+ "',"
+ firstname + "',"
+ lasttname + "',"
+ address + "',"
+ country + "',"
+ email + "')";
OP, at some point you're just going to have to bite the bullet and do something for yourself. It's no good just getting one answer, then going "ok, now how about this?" all the time, people will get fed up answering you, and, more importantly, you won't actually be learning anything. You need to be able to adapt what you've already found out, and apply it to new problems
I agree with george, read some tutorials on how to use Strings. Here's one: http://java.sun.com/docs/books/tutorial/java/data/strings.html
well i can't find the error myself,before posting my question in the forum i try to debug myself and then search on the net .but i m not getting the sql syntax properly to apply in java.according to me the statement is correct,but the compiler is telling me cannot recognize the customer method.
first of all customer is not a method,it is the table name in oracle.
plz help me or give me a link which uses sql statements in java program.i don't need sql syantax.i need how it is written in JAVA program.
String queryinsert = "INSERT INTO" + customer ("cust_id","cust_first_name","cust_last_name","cust_address", "cust_country", "cust_email") +" VALUES"+"('" + custId+ "',"
+ firstname + "',"
+ lasttname + "',"
+ address + "',"
+ country + "',"
+ email + "')";
}
error is
: cannot find symbol
symbol : method customer(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class DressServlet
String queryinsert = "INSERT INTO" + customer ("cust_id","cust_first_name","cust_last_name","cust_address", "cust_country", "cust_email") +" VALUES"+"('" + custId+ "',"
Your problem isn't sql syntax, it's java syntax. You need to make a complete java String before you worry about if it's a valid sql query. The reason it's saying customer is a method is because you gave it the syntax of a method. customer(...) is a java method. You need to learn the difference between String literals and variables. The sql query is just text as far as java's concerned.
GOSHnobody is understanding my questioni know java basics.i don't know how to insert SQL statements in JAVA.
> GOSH
> nobody is understanding my question
> i know java basics.
> i don't know how to insert SQL statements in JAVA.
No, sorry, you don't. I'm not trying to be mean, I'm trying to help you out. You need to read up on how to use String literals. If you can't recognize that this is the syntax for a method:
customer ( "blah", "blah")
then you need practice.
A simple sql statement could look like this:
String query = "select * from someTable";
Notice that this is all one single String literal. If you wanted to replace one of the words with a variable's value, then you'd do this:
String theTableName = "cutomers";
String query = "select * from " + theTableName;
See the difference?
> GOSH
> nobody is understanding my question
> i know java basics.
> i don't know how to insert SQL statements in JAVA.
It is not that people do not understand your question; you are not understanding the error messages.
The last error you posted is a Java compilation error, not a SQL error:
error is
: cannot find symbol
symbol : method customer(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class DressServlet
You are calling the customer() method incorrectly.
> You are calling the customer() method incorrectly.That's what I thought too, but in reply 10 he says that customer isn't a method, it's a db table. It should be a part of the literal.
ya RIGHT it is db table.
i solved it myself
String queryinsert = "INSERT INTO" + "customer"+ ("cust_id" + "," +"cust_first_name" + "," + "cust_last_name" + "," + "cust_address" + ", " + "cust_country" + "," + "cust_email") +" VALUES"+"('" + "custId"+ "',"
+ "firstname" + "',"
+" lasttname "+ "',"
+ "address "+ "',"
+ "country "+ "',"
+ "email" + "')";
}
thx to all
tho next question coming up in new thread " lol"
Ok, well I'm glad it works, but there's no reason for all those words to be broken up into their own Strings. That could all be one long String and be a lot more readable. There's also no need for the parantheses, they don't actually do anything. Maybe you wanted them to be included in the text of the String?
Add this right after that line to see what you ended up with:
System.out.println(queryinsert);