English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to execute and SQL query in java using the method executeQuery(String) of Class "Statement" i.e.
Statement stmt = null;
stmt.executeQuery(sql); /* sql is an insert statement in sql */

However, I am getting message of an exception of the class "SQLException" saying, "There was an internal database error". The thing worth mentioning is that when I fire the same "insert" statement denoted by string "sql" directly onto the database, the query gets fired successfully.

What is the root cause of this problem where in the query is getting fired direclty in the database but not in java?

2006-10-25 18:59:21 · 3 answers · asked by chinmay p 1 in Computers & Internet Programming & Design

3 answers

try this inside your class
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:");
Statement stmt = con.createStatement();
stmt.executeQuery(sql);
}
catch(Exception e){
}

good luck.

2006-10-25 19:16:35 · answer #1 · answered by Anand 3 · 2 0

here connection may be the culprit. Also special chracters in ur insert values can cause the error.

2006-10-25 23:05:29 · answer #2 · answered by Demo 3 · 0 0

I THINK THE PROBLEM IS WITH UR LINKING TO THE DATABASE FROM JAVA, CHECK THAT THE CONNECTION IS PROPER

2006-10-25 19:57:09 · answer #3 · answered by sunny 2 · 0 0

fedest.com, questions and answers