Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MySQL & JNI  RSS feed

 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone here have any experience with using JNI to embed MySQL within a java application. MySQL is written in C, and they give an example of how to embed it within a C probram but nothing for java. Having no experience with calling native methods I'm wondering how tough this will be. Is JNI the type of API that you really need a book for?

Any thoughts would be appreciated.

ms
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you like to embbed mysql in your java application and not use jdbc?
Any particular reasons? You might consider another java embeddable db (HSQL, Berkley DB, etc).

--
./pope
[the_mindstorm]
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be using jdbc. Only, instead of my app accessing a separate server the dbms will run as part of my app. That way I don't need to force users to install and run mySQL themselves. The complexity of installing MySQL will be too much for most of my users.

ms
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case I would suggest to take a look at the above mentioned solutions, that are prooved to be easy to embbed.

--
./pope
[the_mindstorm]
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does every instance of the application access its own version of the database? If that's the case, I would recommend looking at a database designed for such useage, such as HSQLDB (which I use to great effect...) Keep MySQL as a server-side database, and I think that you will have far fewewr headaches.
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's interesting that while thinking it over at work today I reached the same conclusion. I'll just pass a parameter in to tell the app what db to use and have it use HSQL for the embeded version and MySQL for the server version. That way I can easily add more db's if desired down the line.

I'm planning on using resourceBundle to hold the sql strings for each db.

thanks

ms
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great to hear that our opinions/experience is confirmed by your research .

--
./pope
[the_mindstorm]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!