Results 1 to 17 of 17
  1. #1
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default J2SE and Java DB

    Greetings,

    My Java experience is limited, but I have a fair enough understanding of it. With that in mind, I am attempting to write a mobile application with a self-contained database -- Java DB -- for the purpose of maintaining my fitness log.

    Netbeans is my preferred IDE, and it is currently of the latest stable version and Java DB is installed -- indeed the database is ready and waiting -- but I simply cannot figure out how to attach a Java DB to a Java ME project.

    Searching for tutorials and what not online lead me to Java Desktop Applications w/ a self-contained database, and when I attempt to port the import statements to a Java ME project, I receive nothing but import errors -- even with adding the Java DB jar files to the project library.

    Any assistance or point in the right direction would be greatly appreciated. Also, I am not deadset on the use of Java DB, and so if another portable database is preferable, then I am open to suggestions.

    Thank you
    Last edited by port22; 12-02-2010 at 02:28 PM.

  2. #2
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    Without exact errors difficult to help. Here is link for Working with the Java DB (Derby) Database from NetBeans documentation you may already seen it.

    As for the mobile application and database connectivity you can either access website and through servlet run you queries (basic mobile to servlet communication is explained in Beginning J2ME - From Novice to Professional, chap 10) or try to use SQLite but you have to be on BlackBerry platform (Getting Started with Java and SQLite on Blackberry OS 5.0)

  3. #3
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Aye, I have seen that first link, perused it and other available links.

    I can find nothing which addresses how to connect to a Java DB from within a J2SE project or how to distribute Java DB with a finalized J2SE application.

  4. #4
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    Can you explain what you want to distribute in DB with your application? What your application is supposed to do and why you want to distribute DB?

    If you just want application to be able to generated table structure then just write a mechanics to check if table structure exists or not. If it doesn't exists then run a method to do it. Simple like that. Or even better use Hibernate take care of it.

  5. #5
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    I need to store data, both initially distributed with the application and created by use of the application or user. This data needs to remain even after the app has been closed. I read that J2SE apps do not have access to the filesystem, and so I am not able to use flat files. Also, the app will not have internet access.

  6. #6
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    Any Java can read files JME/JSE/JEE.

    Also would be good idea to request this thread to move in different section as what we so far discussed has nothing to do with mobile development

  7. #7
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    The app is explicitly for a mobile device running Java MIDP 2.0. I mistakenly used J2SE in the title and body, but I am using Java ME.

  8. #8
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    We just waisted half day on something that could have been solved with one post.

    If you want to use a database styled system on JME device you have to be either developing for BlackBerry, hence the link in my first reply, or you have to go with RecordStore that is available on any JME enabled device (crude, but efficient).

  9. #9
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    The record store won't provide nearly the amount of storage space I need... :-(

    Java DB seems to imply that you can bundle it with a mobile application.

    Did I recall correctly that Java ME apps do not have access to read / write to file system files? If they can, then I can simply do everything as XML...

  10. #10
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    You can read text files or browse folder structure with JSR 75 - PDA Optional Packages that provides File Connection together with Personal Information Management (PIM). Folder browser example here

  11. #11
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    PS: Can you point me where you read that Java DB can be used in midlets?

  12. #12
    port22 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Just the features at a glance page implies it: http://www.oracle.com/technetwork/ja...iew/index.html.

  13. #13
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    Hmmm, finally I found something on Db-derby Wiki - Using Derby on Java ME platforms, but there isn't much to go on with...

  14. #14
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    If what I understand is correct, what u want is J2ME application with database, that will run on client mobiles. Both application and database will be inside mobile.
    Derby is good but it is slower than other db in many respect. My choice is H2, For more look at the link
    Open Source Database Engines in Java
    and going back to your 1st post,
    but I simply cannot figure out how to attach a Java DB to a Java ME project.
    Inculde derby.jar file into project and try this :
    Java Code:
    Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
    	connect = DriverManager.getConnection("jdbc:derby://localhost/c:/temp/db/FAQ/db");
    What it does is create new database named FAQ.db at given path when application is runned.

    -kind regards

  15. #15
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    Just please note that

    Java Code:
    Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
    	connect = DriverManager.getConnection("jdbc:derby://localhost/c:/temp/db/FAQ/db");
    is giving absolute path for PC that is not applicable on mobile device. You will need to come up with variant for mobiles

  16. #16
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    is giving absolute path for PC that is not applicable on mobile device. You will need to come up with variant for mobiles
    It's true, it gives absolute path. I was giving example on how to use, not the exact code.

    -Kind regards

  17. #17
    peter_budo is offline Member
    Join Date
    Dec 2010
    Posts
    49
    Rep Power
    0

    Default

    @Prajin I wasn't picking on your code, just making port22 aware of the fact since he is beginner

Similar Threads

  1. Java main method (J2SE)
    By myka in forum Advanced Java
    Replies: 2
    Last Post: 03-19-2010, 07:59 PM
  2. Replies: 1
    Last Post: 09-25-2009, 02:16 PM
  3. Difference betwen Core Java And J2se?
    By makpandian in forum New To Java
    Replies: 6
    Last Post: 02-28-2009, 06:55 PM
  4. Java J2SE Bluetooth Application
    By mark305 in forum New To Java
    Replies: 1
    Last Post: 02-23-2009, 09:02 PM
  5. J2Se and Java
    By sweetnuts in forum Introductions
    Replies: 0
    Last Post: 10-19-2008, 10:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •