I need to fetch DB2 data from user libraries on an IBM i machine using Java. I'm using JTOpen400. Can anyone please help?
You have to rephrase your question. RPGLE files does not exist on an iSeries. Everything is a DB2 table (which can be used with RPGLE offcourse).
If you have JTOpen400, then I advice to use JDBC. With JDBC the iSeries is a regular DB2 database server. It works like any other database server. Just follow the JDBC guidelines as describes in many books, manuals and websites.
Check SequentialFile for this. Remember to set the record format, and then you can pick out the fields for each line as you iterate them.
You can use JDBC (driver provided by JT400) to access DB2/400 files on the iSeries just like any other database.
The JDBC URL would be something like jdbc:as400://system-name/default-schema;properties
See http://javadoc.midrange.com/jtopen/com/ibm/as400/access/AS400JDBCDriver.html for more information.
Related
I have MySQL installed, but It takes more than 1 GB of C drive. However the database file is only some KB's. I want to help to transfer the database file into single file that is in the Java program data folder. Also i want to know how to change the connection to be that file instead of using JDBC?
Thank you.
So a fast edit after long time ago 😂
that day i meant that I want to use something like SQLite instead of MySQL
I think that clarifies it now
waiting for new answers.
First of all, you questions is structured in a way that i do not fully understand it. However let me make things clear.
In order for java program to connect to Database you need a driver ( typically JDBC ). The database HAS to be on some sort of "server" i.e apache, sql server, derby etc. If you want to save some HDD space i suggest looking into Derby Database, which is "integrated" database
EDIT:
Or you can just host external database on some hosting server ;), there are some free ones out there too !
You might want an embedded database, like h2 or java Derby.
Such an embedded database often is stored as file, without external database engine runnin (it might do that too though). The API remains JDBC.
What I needed was mySQLite, it's saved on the device as a single file and easily managed through java.
What you need to do is to export the mysql database
And use dbmigration app to convert it to sqlite then use your database as you wish
I wonder if it's possible to use the database file from mysql, without having a server running. Just copying the db file and place it somewhere, then use "jdbc:mysql://localhost:3306/table";
and change it to something like "jdbc:mysql://C:/Users/me/Desktop/table";
Will this work or is there a better way?
This is not possible with Mysql. Sqlite is a Serverless database designed for this purpose.
You're probably looking for an embedded database, i.e. as you say a library that is able to access a database on a file without a server.
MySQL has an embeddable version: http://www.mysql.com/oem/
You might want to check also H2: http://www.h2database.com/
Or Apache Derby: http://db.apache.org/derby/
Or HSQLDB: http://hsqldb.org/
Short answer: no.
Long answer: You'd have to basically recreate the MySQL daemon in Java. In particular, JDBC would have to know the structures inside of the file. The files are quite complicated, and this would be quite a pain.
This means you would have to basically write your own code capable of parsing and manipulating MySQL files. This would be a horribly complex task.
Yes, there is a better way. If you want to use MySQL, use MySQL.
Another option would be to use the embedded version of MySQL, or something like SQLite.
I am currently undergoing a project which requires a database. So far uptil now I have been using a sql localhost database, I was wondering if there was an alternative to this.
Similar to micrsoft access database where I could read from the local database file instead?
It sounds like you are talking about an embedded database.
Take a look at: http://www.h2database.com/html/main.html
You could use Hypersonic or Derby; the latter is part of the JDK now. SQLite is another possibility.
I need SQL functionalities for a Java JSE application, but dont need a whole SQL server, with things like listen on a port, connection string or even a standalone process to be runned or configured.
I also would prefer to work with files as storages, so that file path identifies DB data.
So given to the DB API the name of a file, I would need perform SQL with the file as DB storage, supporting tables, search, joins and inserts, without thinking to things like ports, external processes, server installation, ecc..
Without any other configurration action, since any other configurable feature is not needed.
Is there some library, preferrably installable as single .jar, that provides this functionality?
If there is not this library, which file-based DB is the simplest to configure and use within JSE, and which configuration steps are needed to perform a query in the provided DB and deploy it with (working) the java .jar application?
I suggest Derby db.apache.org/derby/
I like H2 Database very much. It compares very well with other database engines.
Sure, Hypersonic SQL or Derby, the database that comes bundled with Java 7, will both fill the bill. SQLite would be a third alternative.
you may want to check this out:
http://www.sqlite.org/
I have used HSQLDB in the past and liked it. Depending on what your needs are, you might also be interested in JoSQL which allows you to do SQL type of queries on java collections.
I would like to know how can I use php-java bridge but only to connect to database ..and then i would like to use PHP to view data from DB, to update data from DB and to delete data from DB through PHP files(interface)
What Database are you using?
If you use MySQL, SQLite or MongoDB, there is no need for a bridge since Java can connect to all of them directly. To connect to MySQL (for example) you would use JDBC.
I've done it using Zend Server Community Edition - it has a java bridge option that I am currently using.
However...I have a different opinion on how to get to your destination thast will be faster and easier. To have the ability to switch out databases or use multiple databases is easy in php - use pdo, and you'll be able to keep it generic. You can even connect to MSSQL if you wanted to - it's all there. With PDO prepared statements (your queries) you'll also have similiar security without creating an additional database layer.
Please note: If you already have Java code already written to server as a model, however, rock out!