I am trying to build a simple GUI in which you can write some Integers. These Integers are supposed to be written into a Database, which I am looking for.
So far so good. The data in the Database should then be used for another stand-alone application, which already exists.
I tried it with SQLite already but I received a lot of "Database locked" Errors. I searched Google. The key answer I often read about was to switch to a database which supports concurrent processes.
I went further on and had a look at H2 and HSQLDB. Both of them seem to be legit but much more complicated.
So I wonder:
I would like to have the GUI to be portable in a .jar file (or a folder only) combined with the Database, so when I switch computers I do not have to install the DB in a certain folder like the home-directory or something. With SQLite all you do is this:
Connection con = DriverManager.getConnection("jdbc:sqlite:test.db");
As you can see, no Path-infortmation is necessary. How can I do this with H2 or HSQLDB?
I am really looking forward to your suggestions. But only open source please.
Kindest regards and thank you very much!
Stefan
With H2 and HSQLDB you can do the same.
With H2, a database URL of the form jdbc:h2:test will create a file called test.h2.db in the current working directory of your application. If this is what you want, then that's fine. Please note I usually don't suggest to do that, because many people run into the problem that they sometimes start the application in a different directory (which will then create a new database). Because of that, I suggest to use jdbc:h2:~/test, which means the database file is stored relative to the current user home directory.
Handling the creation of an embedded db file should not be a big issue - but if you really dislike this stick with SQLite: it should handle concurrency well enough for basic usage - 'database locked' sounds more like an application level problem
Related
my question is:
how to connect java tp paradox / borland database ".DB" single files?
Here's what I have:
So, it's Paradox 7 database files.
I'm trying drivers:
http://www.hxtt.com/paradox.html & https://code.google.com/archive/p/paradoxdriver/ as:
String url = "jdbc:paradox:/D:/BABAK/powerGold/SongTitle.DB";
Connection con = DriverManager.getConnection(url);
But both throws exceptions like:
D:/BABAK/powerGold/SongTitle.DB isn't a database directory path!
As you can see, it is trying to find some database folder, but I have only single files! Also, "jdbc:paradox:/D:/BABAK/powerGold" (path to all .DB files folder) didn't work as well.
So, anybody, please help me to figure out, how to open this type of DB in my Java app.
jdbc:paradox:D:/BABAK/powerGold is the correct syntax.
One of the open source Paradox drivers you mentioned is now on Github and has had more features added since a couple of years ago, so that may now work.
If it doesn't, can you post the full stack trace (using this library, not the HXTT one) so we can figure out exactly what's going on? I'm not the original author, but I have made several contributions for different field types.
you're not trying to open the database doing so but a specific file of the whole DB. In fact your DB is composed of files .db, .px ....
The best approach to do so, is to migrate since this DB is not supported, and realy brings a lot of bugs.
I will recommand you to use migrate your database.
install Paradox Database Reader or Editor
export tables to CSV files
import tables in mysql Database (for example)
If you still want to connect this DB without migration with java, share in private a file .db and will give a try now.
To solve it do the following:
String url = "jdbc:paradox:/D:/BABAK/powerGold/";
keep the same files .db and .px of SongTitle in the same directory then run your code and it will work
I have a Java desktop application (a runnable jar) that is being made available to clients within a CD. Then "autorun.inf" automatically launches the jar and the application runs from the CD (therefore running in a read-only environment).
This application needs to access some known data and use it somehow. Since the application is standalone, this data should be distributed with the application in some kind of files.
Now comes the challenging goals:
This data are just columns of numbers, similar to database table exports. And the most convenient way to access it would be exactly like if it was a database table where one can do SQL queries to this files.
This data should be confidential to the user clients. Although the data must be distributed with the application, it cannot be legible to users. So, the data must be encrypted or obfuscated somehow.
So I kindly ask for your help mainly to point me some ideas that will help me understand and discuss with you which is the best way to implement such features.
Thank you very much in advance,
Alves
Edit #1:
Using an embedded database engine is a great idea and would solve both problems at the same time. But it raises some questions for me:
Does the database engine needs to write files somewhere? I've done some tests with HSQLDB and I think it does. That would be an issue since the application is running from a CD.
If it really needs to have such files, can I release them also with the application, instead of being created on the fly?
Just to confirm, if I use an encrypted database, I have to put somewhere on the application the secret Key that will make me decrypt it, right?
One possibility would be the use of an encrypted SQLite database.
SQLite is a relational database management system, where the databases are files.
For encryption in SQLite look here: http://www.hwaci.com/sw/sqlite/see.html
Your goal is absolutely impossible and it's rather obvious why: Your application obviously needs to read the encrypted data (otherwise why bother including it), hence has to decrypt it, hence has to store the keys somewhere.
Well there you are: You sent the encrypted data AND the key to decrypt it to the client - what's to stop them from doing the same thing your application does?
Yes it may stop some people from getting your data, but it's nowhere safe against someone who has even a slight understanding of what's going on
You could use SQLite with the SQLite Encryption Extension.
The SQLite database file could be created at the first start of you application.
You can simply test if the SQLite database file already exists:
if (!new File(database_filename).exists()) {
createNewDatabase();
}
The path to your SQLite database is stored in the database_filename variable.
If the file doesn't exist already, you can save the file for example in the user's home dir.
I'm using the following code in one of my applications to create the database with an external SQL script file.
public final void createNewDatabase() {
InputStream inputStream = getClass().getResourceAsStream("database_create_script.sql");
String sqlCommand = new Scanner(inputStream).useDelimiter("\\A").next();
try {
Statement statement = connection.createStatement();
statement.executeUpdate(sqlCommand);
} catch (SQLException ex) {
ex.printStackTrace();
}
System.out.println("Database created");
}
H2 Database supports encryption, too. As much as I like SQLIte, for a Java application I'd choose H2.
I'm trying to create a Packaged App for Chrome using GWT, I need an SQLite DB. I can't seem to find any decent resources on doing this. I've looked at gwt-mobile-webkit, is that the definitive way to use sqlite in gwt? I'm getting errors when I follow their example, it seems it hasn't been updated in awhile. Based on the lack of results I'm thinking I'm not searching for the right thing, any guidance?
I'd check out gwt-mobile-webkit, or more specifically the Database API. Though the name says "mobile", it definitely works on the desktop. This library wraps the HTML5 database support, which (depending on the browser) is either SQLite or IndexedDB. There are plenty of other, heavier weight wrappers, but this is the best and easiest I've seen around.
alright, after a few hours of searching and reading all over the net, I have broken down and decided to ask for help. I am working to automate many of the more medial and repetitive tasks as work, and stumbled upon AutoIt, I love the tool. anyway, Today's task is the export of a slew of tables and queries from Access 2007 in a few different formats. mostly CSVs some Tab delimited, and a couple of dBase DBFs and DBTs. now none of this is all that difficult and in fact the person who previously held my position created about a hundred Macros in the mdb that export the tables. seems to me that he fell well short of hastening the process as you still have to run each macro. I am looking to create an autoit script that will export the correct tables in the correct format to the correct place with the correct name. doesn't seem like it should be that difficult.
so thus far I have been imagining using ADO to tell Access to export which table in which format and where. but I cannot seem to find the necessary commands needed to do that. I also figured that perhaps, at least with the text based formats (CSV, txt, tab) I could read each record out of a given table or query and then build the text file myself in autoit, not the simplest way of doing it, but it could work. The problem arises when trying to create the dBase file, I haven't a clue where to begin with that.
I am open to using JAVA, AutoIt, PHP, or Perl to accomplish my task.
I should note that I am fairly new to ADO. the syntax in ADO seems to elude me frequently. so, any and all help is appreciated, please refrain from the "Just google it" responses. if you have a link to share, or a resource that you have found helpful please post that as well, I am not allergic to reading or doing research. Sometimes it just makes more sense to ask for help.
Thanks,
Kyle
If you are open to using VBA, you could probably make it work with only a little code and the DoCmd-Object.
To export as CSV, have a look at DoCmd.Transfertext
To export to dBase, have a look at DoCmd.TransferDatabase
If you have questions about using those, just ask in the comments and I will provide more information.
This is a sort of bonkers idea, but if you already know Java, you may be able to get this to work with the JDBC-ODBC bridge. You'll first have to register your particular Access database as a named ODBC data source, as the bridge does not appear to support on-the-fly ODBC. I don't have a Windows machine on hand and don't remember the exact sequence of steps to do that, but it should be available from the ODBC driver manager.
Short Version: I need to store some data between runs of a java program.The data will be of the form of a table.Is there anything that can let do something like a sql query in java??THE SOLUTION MUST BE ABLE TO RUN ON AN OFFLINE COMPUTER.
Long Version: The user will be entering some data daily and i want something like a sql table in java. The program will run on a computer that is NOT CONNECTED TO THE INTERNET and so i need a truly local way to store data(Lots of it).Also preferably the data should be stored in such a way that it is not easily accessible to the end user(as in ,he should not be able to double click the file and simply read its contents)
Major Constraint: On searching online i found many people were using localhost to solve similar problems but that facility is not available to me as i CANNOT INSTALL ANYTHING on the target computer.
If a simple data file is not good enough, how about using SQLite with a JDBC backend? It will allow you to have an SQL database stored in a regular file with no dependency on any kind of server. Alternatively, there are many other embedded DB engines that you could use, depending on your needs.
EDIT:
By the way, most (if not all) DB engines that I know of do not obfuscate the data before storing them in the filesystem. The data will be fragmented, but parts of it will be visible if you force an editor to open the file (e.g. using "Open with..." in Windows).
There is also nothing to stop your user from accessing the data using the command line utility of the selected DB engine. If you want to obfuscate the data you have to do it in your code. Keep in mind that this will not stop a determined person - if your application can read it offline, so can everyone else.
Use an embedded database (like Apache Derby, HSQLDB, H2) so that you don't have to run a database server on the machine. The data will be stored locally on the target machine and it won't be human readable.
You have several options:
Store it in an xml-file
Store it in an local installed database
You can install a database like mysql or use a in memory database like sqlite or hbase or apache derby, which is included in java 6