inserting strings in a database

Hello all!

I am trying to insert string values in a database with this metode.

publicvoid insertData(){

[code]try{

String url ="jdbc:odbc":"+database;

Connection connection = DriverManager.getConnection(url, user, password);

Statement status = connection.createStatement();

status.executeUpdate("INSERT INTO radiograhy (Title, Red, Green, Blue,"

+"Hue,Saturation,Value,Color,Path,IdRadiography,Description) VALUES "

+"("+Title+","+Red+","+ Green+","+ Blue +","

+ Hue+","+Saturation+","+Value+","+Color+","+Path+","

+IdRadiography+","+Description+")");

}catch(SQLException e){

e.printStackTrace();

System.out.println(e);

}

but the metode throws me an exception :

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

[1557 byte] By [aurelian_cla] at [2007-11-27 5:57:44]
# 1
well how did you install the driver and made it work? **** i am still stuck on installing jdbc and microsoft system dsn odbc..
lrngjavaa at 2007-7-12 16:31:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.I have a syntax error and I don't know what I made wrong. Not the driver is the problem.
aurelian_cla at 2007-7-12 16:31:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
put all the values corresponding to string fields in ' value' .
Yogesh.Nandwanaa at 2007-7-12 16:31:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

This has actually nothing to do with JDBC, but with basic SQL knowledge.

Print the complete query using System.out.println and try to find out what's wrong with it. Play with it, execute it right on the DB, etcetera. If you don't understand it, then don't bother to read some [url=http://www.google.com/search?q=sql+tutorial]SQL tutorials[/url] how to write clean SQL.

Once you understand SQL, I would also recommend you to use PreparedStatement instead.

BalusCa at 2007-7-12 16:31:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...