DB Connection problem in java

Posted on 2009-07-07
Last Modified: 2013-11-23
Hi ,

i am using below code when i run java envi its says ORA-00911: invalid character
that same query is runing and insert the values in back end !!
can u tell me the problem
String url = "jdbc:oracle:thin:@localhost:1521";

		  try {

				try {


					// System.out.println("Failed to load isqlPlus driver.");

					//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());


				catch (Exception ae) {



				try {

					String url1 = System.getProperty("JDBC_URL");

					if (url1 != null)

						url = url1;

					Connection con = DriverManager.getConnection(url,

							"system", "tspl");

					PreparedStatement psmnt=null;

					String query="insert into gen_info(EMP_NAME,EMP_ID,TECH) "+ "values(?,?,?);";

					//Statement st=con.createStatement();


					psmnt = con.prepareStatement(query);





				boolean s = psmnt.execute();

					if (s)


						System.out.println("Succesfully inserted");




						System.out.println("Cant Insert");




				} catch (Exception e) {



			} catch (Exception e) {



Open in new window

  • 2
LVL 92

Expert Comment

ID: 24792896
try getting rid of the ;
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 24792903
what i didnt get u ??
LVL 92

Accepted Solution

objects earned 500 total points
ID: 24792911
the ; at the end of your sql
LVL 15

Expert Comment

ID: 24792944
in line 21 , will it cause by missed space in sql statement?
String query="insert into gen_info (EMP_NAME, EMP_ID, TECH) "+ " values(?,?,?) ";
also, you can try System.out.println(query) to see is there any invalid characters ?

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 127
sites similar to codingbat to improve coding hanson skills 3 41
Java - Why doesn't this JFrame work 3 44
eclipse java  build path 6 45
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now