• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Connect to SQLite & do work [SOLVED]

 
Greenhorn
Posts: 4
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Community,

i programming to time a Program, that are for my Buisness. In this Program i will do the follow things:

  • Connect to SQlite
  • Create Database when not on System
  • Create Table when not already there
  • Read/Write things in Database


  • now i have write a connection.java . The Connection was established. After this i have do a if&else to find out, is the database as data there and when is not there then create. After this Point i do anything false! Here my Code:


    Every Time when i start my programm he goes in the "createNewDatabase();" Function and dont find out, that the database is already there. Anybody has help for me ?
    Best Regards
     
    Saloon Keeper
    Posts: 21254
    137
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Wilkommen in die JavaRanch, Patrick!

    I'm afraid your meaning is not entirely clear on account of your not being quite the precise English, but I think I may see what your problem is.

    SQLite is not like most SQL DBMS's in that its primary operating mode is against data in a simple disk file or in memory and not as a separate server program. You appear to be checking to see if that file exists before trying to open/create that database file.

    However, your argument for File.exists() is not correct. File refers to an object in the locally-accessible filesystem only and therefore the path you must use is a traditional filesystem path and not a URL.

    So:

    Note that this statement contains a RELATIVE filesystem path, which can result in problems if the user is not attached to the proper working directory when the code is run. But it is a filesystem path and not a URL, and that is what is important.
     
    Patrick Bloch
    Greenhorn
    Posts: 4
    Eclipse IDE Firefox Browser Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hey, thanks for your answer. I have try and itś work ^^ So much thanks to you!
    Well my English is not the yellow from the egg, but i will do my best to learn and write english better.
    Thanks for the Solution. With the Relative System I will read more. The whole thing is to learn a little while ^ ^
     
    Tim Holloway
    Saloon Keeper
    Posts: 21254
    137
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Patrick Bloch wrote:... the yellow from the egg,



    That's a good one. Hadn't heard it before. I think my favorite is still "dragging me through chocolate", though.

    Considering that English and German have a common ancestry, they can be awfully hard to think across. Some words and constructs diverged at 45-degree angles over time. One that I think notable is "let=lassen". In English, "I let someone cut my hair" implies permitting someone. In German, »Ich lasse mein Haar schneiden« is more like commanding someone.
     
    Patrick Bloch
    Greenhorn
    Posts: 4
    Eclipse IDE Firefox Browser Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Maybe you can help me again. Or one. Then I do not have to open a new area for the topic.
    I am currently building the area where the tables are created, the first table is created. At the second he tells me then but that:

    SQL error or missing database (near ")": syntax error)



    does anyone have any idea what could be wrong? Here is my Code again:

     
    Tim Holloway
    Saloon Keeper
    Posts: 21254
    137
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Actually, when you have a new question, we prefer that you start a new topic. We don't charge extra

    More seriously, it's easier when other people have the same problem to search for a topic than to look through a lot of unrelated stuff.

    I think probably that the fault is that you end your SQL statements with ";". The terminating semi-colon isn't actually SQL. It's generally used by interactive SQL utility programs to tell the program to execute the SQL statement, although that depends on the utility program used and its options.
     
    Oh. Hi guys! Look at this tiny ad:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!