Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql syntax how to write it down in java

Tags:

java

sql

i want to write this line in an sqlight db b:

CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')

therefore in my java file who generate this data base i am doing :

stat.executeUpdate("create table "+"android_metadata"+"("+"locale"+ " TEXT DEAFULT"+");");
    PreparedStatement prep1 = conn.prepareStatement(
              "insert into "+"android_metadata"+" values (?);");
    prep1.setString(1, "en_US") ;

but the output is not similer how do i make the sqlight locale be "locale" with "" in the declaration and the field locale would be just TEXT

as similer to this blog start : http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

thanX

like image 372
yoav.str Avatar asked Jul 03 '26 17:07

yoav.str


1 Answers

To escape the double quotes use a backslash:

stat.executeUpdate("create table \"android_metadata\" (\"locale\" TEXT DEFAULT 'en_US');");

Also I think you don't need double quotes round android_metadata as it is not an SQL keyword.

like image 68
Mark Byers Avatar answered Jul 06 '26 07:07

Mark Byers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!