Results 1 to 17 of 17
Thread: J2SE and Java DB
- 11-21-2010, 10:38 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
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 youLast edited by port22; 12-02-2010 at 02:28 PM.
- 12-01-2010, 02:15 PM #2
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
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)
- 12-01-2010, 05:46 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
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.
- 12-02-2010, 09:51 AM #4
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
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.
- 12-02-2010, 12:20 PM #5
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
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.
- 12-02-2010, 01:16 PM #6
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
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
- 12-02-2010, 02:27 PM #7
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
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.
- 12-02-2010, 02:52 PM #8
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
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).
- 12-02-2010, 11:00 PM #9
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
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...
- 12-03-2010, 07:02 AM #10
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
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
- 12-03-2010, 08:49 AM #11
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
PS: Can you point me where you read that Java DB can be used in midlets?
- 12-03-2010, 11:43 AM #12
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Just the features at a glance page implies it: http://www.oracle.com/technetwork/ja...iew/index.html.
- 12-03-2010, 12:02 PM #13
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
Hmmm, finally I found something on Db-derby Wiki - Using Derby on Java ME platforms, but there isn't much to go on with...
- 12-05-2010, 09:10 AM #14
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,
Inculde derby.jar file into project and try this :but I simply cannot figure out how to attach a Java DB to a Java ME project.
What it does is create new database named FAQ.db at given path when application is runned.Java Code:Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); connect = DriverManager.getConnection("jdbc:derby://localhost/c:/temp/db/FAQ/db");
-kind regards
- 12-05-2010, 10:10 AM #15
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
Just please note that
is giving absolute path for PC that is not applicable on mobile device. You will need to come up with variant for mobilesJava Code:Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); connect = DriverManager.getConnection("jdbc:derby://localhost/c:/temp/db/FAQ/db");
- 12-05-2010, 12:00 PM #16
It's true, it gives absolute path. I was giving example on how to use, not the exact code.is giving absolute path for PC that is not applicable on mobile device. You will need to come up with variant for mobiles
-Kind regards
- 12-05-2010, 02:22 PM #17
Member
- Join Date
- Dec 2010
- Posts
- 49
- Rep Power
- 0
Similar Threads
-
Java main method (J2SE)
By myka in forum Advanced JavaReplies: 2Last Post: 03-19-2010, 07:59 PM -
Senior Development Manager - Core Java/J2SE - £80-90K + £10K Bonus
By iNeedJavaGurus in forum Jobs OfferedReplies: 1Last Post: 09-25-2009, 02:16 PM -
Difference betwen Core Java And J2se?
By makpandian in forum New To JavaReplies: 6Last Post: 02-28-2009, 06:55 PM -
Java J2SE Bluetooth Application
By mark305 in forum New To JavaReplies: 1Last Post: 02-23-2009, 09:02 PM -
J2Se and Java
By sweetnuts in forum IntroductionsReplies: 0Last Post: 10-19-2008, 10:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks