Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8830387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:04:28+00:00 2026-06-14T08:04:28+00:00

When I try to create a database programatically in SQLite using java, it generates

  • 0

When I try to create a database programatically in SQLite using java, it generates the following error in console.

java.sql.SQLException: near "DATABASE": syntax error
    at org.sqlite.DB.throwex(DB.java:288)
    at org.sqlite.NativeDB.prepare(Native Method)
    at org.sqlite.DB.prepare(DB.java:114)
    at org.sqlite.PrepStmt.<init>(PrepStmt.java:37)
    at org.sqlite.Conn.prepareStatement(Conn.java:224)
    at org.sqlite.Conn.prepareStatement(Conn.java:217)
    at org.sqlite.Conn.prepareStatement(Conn.java:206)
    at com.mmcal.build.BuildDB.executeQuery(BuildDB.java:46)
    at com.mmcal.build.BuildDB.createDB(BuildDB.java:19)
    at MainGen.main(MainGen.java:16)

My code is :

public class BuildDB {
Connection connection;
PreparedStatement ps;
ResultSet rs;
String qry;

public void createDB() {
    qry = "CREATE DATABASE IF NOT EXISTS myDb";
    executeQuery(qry);
}
public boolean executeQuery(String qry) {
    int cnt = 0;
    boolean flag = false;
    connection = ConnectionMaster.connectDb();
    try {
        ps = connection.prepareStatement(qry);
        cnt = ps.executeUpdate();
        System.out.println(flag);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    if (cnt == 0) {
        flag = true;
    }

    return flag;

}
}

What’s the problem in my code or is this the correct way to create database in SQLite via programatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:04:29+00:00Added an answer on June 14, 2026 at 8:04 am

    With SQLite you just open the database. If it doesn’t exist it will be created for you automatically. Then you can check if your tables exist and create them as required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i get this error when i try to create a database using rake command.
When i try to run the command rake db:create:all it's giving the following error:
I am trying to create a Sqlite database using Monotouch 3.0.3.4. Everything works fine
when I try to create a database in H2 in the web console with
whenever I try to execute this sql command: create database sitename I get this:
i try to create an AEP for my advantage Database. I create a AEP
I want my code to automatically try multiple ways to create a database connection.
I have a Java application communicating with a SQL database via a PHP script,
In my project, current approach is to create database if not already exists using
I try to create database from entity framework code first follow with this tutorial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.