My app connects with diferent databases. First of all, I generate the orm code with speedment for the first database. But when I try to connect to a newone Speedment deletes the code generated for the previous one.
The Speedment Tool can't currently connect to more than one database, but there is a hack to get around this.
Speedment will generate code based on the speedment.json-file. When you connect to a new database, your speedment.json-file is overwritten and is therefore not used in the second pass. To get around this, save the original file as something else (like speedment2.json) and then connect to the second database. Instead of generating, simply press "Save". This will create a new speedment.json-file without generating code. Then open the created file in a text editor and add manually combine the files. Look for an value with the key "dbmses". It should be mapped to a list of objects, in the first file the object represents the first database and in the second file it represents the second database. If you combine these two lists, save the file and then reopen the UI, then you should see both the databases there. From here on you can use the tool to make changes and regenerate code as usual.
Related
[So as you can see in the picture, i'm a newbie in android programming and i just had an assignment concerning creating a management system app for university.
The views you see in the picture are just customly made with xml(Table layout) and the data are just dummy data placed on the respective textviews in the tables. I desire to create a database for students and all those data e.g names, gender, should be fetched from the database or sent. Remember, as for courses the number of courses would differ from one degree prog to another(imagine a student with less ormore courses than the tables i sampled there).
How do i acomplish this
As for database, im thinking of using SQLite or Firebase ]1
There are many ways to approach this, depending on the requirements of your program. If you need to share data between multiple people or devices, you probably want a database that lives on a web server, and you would write an API (application programming interface) which you would call from your app, and it would go and get the data from the database and return it to your app.
If your app is meant to be 'stand alone', where you could use it without being connected to the internet, then yes, a SQLite database is a good solution and it is pretty easy to integrate into your app.
To create a SQLite database, you can download the free tool SQLiteStudio. Once you create the database (usually saved with a .db file extension) you can add it to your project in the Assets folder (create it if it doesn't exist). The folder lives at the same level as the bin and gen folders in your project.
Next, search for a class called DatabaseHelper.java, it has a number of methods for opening, closing and querying a SQLite database, copy that to your project.
At the start of your program, you should check to see if you have a copy of the database in your local data/databases folder in your App's file storage area. If you don't have a copy there, which on the first execution of your program, it will not be there, then you have to copy the database .db file from your Assets folder to the data/databases folder, then open it there. If it is found, you've already done this, so, just open it.
When you want to read data into your app, you execute a SELECT statement to retrieve data from your database into a Cursor object, and return that cursor from your DatabaseHelper class to your activity. In your activity, you will iterate through the Cursor, reading one row at a time, and copy the data into program variables. Sometimes, you will create a class object to hold one record, with attributes that match a row from your query, and you'll create an instance of your class, fill it with the data from the Cursor, then add that object to an Array List of objects which your program can use at a later time, say, to display a list of people or whatever it is you queried for. Once the Cursor has been read to the end, you close the Database by calling a close method in the DatabaseHelper class.
That's the general idea. If you search for a copy of the DatabaseHelper.java class, that will get you started. Then, search for some example projects that use that DatabaseHelper.java class so you can figure out how to use it.
Good luck!!
I'll be direct about my situation right now. I'm working in a project which will perform a "Base load" procedure based on an excel (xlsx, xls) file. It has been developed in java with JDBC drivers. right now this project is working, It takes an excel file and based on a configuration It performances the insert into differents tables. The point is: It's taking too long doing the job, which makes it inefficient. (It takes around 2 hours inserting 3000 records on DB). in the future, this software will be inserted around 30k records and it will be painfully slow. So I need to improve its efficience and I was thinking in: Instead of inserting from java via JDBC drivers. I will generate control files and data files to be inserted in the DB using SQLLDR.
The point I'm facing right now, I need to insert these data into several tables, and this tables are related to each other. That's means, If I insert a person into "Person_table" I will need the Primary Key generated by a database sequence to insert the "Address, Phone, email, etc." into other table, so I do not know how to get the primary keys generated in the first insert via SQLLDR.
I'm not sure sure yet if SQLLDR is my best way to do this, but I guess It is, because the DBMS is Oracle
Can you guys lead me about how could I do what I explained you guys I need to do? any suggestion is welcome and well received. It does not matter if your suggestions are not about how to do this with SQLLDR.
I'm a kind of stuck at this point right now, I really appreciate the help you could give me.
SQL*Loader can't read native Excel files (at least, as far as I know). Therefore, you'll have to save the result as a CSV file.
As you need to manipulate foreign key constraints, consider switching to external tables feature - basically, the background is still SQL*Loader, but you can write (PL/)SQL against those files/tables (yes - a CSV file, stored on a hard disk, acts as if it was an Oracle table).
So, you'd "load" one table, populate primary key values, populate another (child) table - possibly into a "temporary" (not necessarily a global temporary table) which doesn't have any constraints enabled, populate foreign key values and move data into a "real" target table whose constraints now won't fail.
Possible drawback: CSV files have to reside in a directory that is accessible to the database server, as you'll have to create a directory (Oracle object) and grant required privileges (usually read, write) to user who will be using it. Directory is usually created on a server itself; if not, you'll have to use UNC while creating it.
Now you have something to read about/research; see if it makes sense to you.
Just started out with my hobby project and now I am here to get help with making the correct database design/query. I have made a simple Java program that loops trough the content of a folder. I want to save this content to a MySQL database, so I added a connector to my database in Java, created a table and the columns "file", "path" and "id, "date" in MySQL.
So now to the important/fun thing, every time I want to add the filenames to the MySQL in Java I do this (when the GUI-button is pressed I call on a method that does):
DELETE all entries with the same file path - this is to ensure that I will get new entries which is exactly the same as the content in the path.
Java-loop: INSERT the file-info into the columns id, path, filename and date when the file was added to the database.
In this way I can always ensure that the filenames that are going to be added into the database always are up to date, it doesn't matter if I rename a file or remve it, it will be up to date since the table will get it's entries deleted and new info will be written. Old info -> DELETE old info - INSERT new info -> Up-to-date.
I know this is probably not the best solution but it works, but now I am stuck on the next thing I want to do. I want to add the difference of the files in order to know which files has been added and deleted between two inserts, and here is my problem, since the entries are deleted before a new INSERT I cannot compare. How would you change the design or the solution? All ideas are welcome and since I am so fresh I would really appreciate if you could show me how the query could look like.
Do not remove all rows first. Remove only the ones that are removed (or event better, just mark them "inactive" as I suggest below). Query your DB first, to see what was there last time.
I would maintain additional column in your table called "inactive". It will be FALSE as default, and TRUE for removed files. Please keep in mind that as your file is uniquely identified by file+path+id renaming any file is indeed an operation of deleting the old one and creating the new one.
Removing things from DB is not a good idea, as you might always remove something by accident (bug in the code) and would not be able to get the data back.
Additional thing to do is adding the hash to your table. This way you will be able to check if the file was really changed. There is no need to re-add the file to the DB is it is not changed. See Getting a File's MD5 Checksum in Java for more info.
One way to achieve this is to implement auditing of your table. A common approach is to create a copy of the table where you are storing the folder contents and name that table using a convention to indicate it is storing audit information (eg. _AUD) . You then add additional columns to the AUD table, like "REV" (revision), "REV_TYPE" (inserted, deleted, modified). Whenever you insert, update or delete any rows from your main table, you insert a row into the AUD table to describe what you've done. Then you can find the operations associated with each revision by looking it up in the AUD table. A java framework that provides this feature is hibernate envers (http://hibernate.org/orm/envers/).
There is a lot of tutorials out there showing me how to create a new table and ammend the data. But will creating a new table every time overwrite my existing table?
Once the table has been created and the rows of data have been added, I wouldn't need my program to create a new table again. Just read and ammend from it.
I don't want the user to create a table, so I just want the table to already be there before I even run my program.
I figured I could use run something like this to create my database tables once:
https://www.tutorialspoint.com/jdbc/jdbc-create-database.htm
Run it! And then once it is created, use this next guide to connect to where I stored it in the actual program.
https://www.tutorialspoint.com/jdbc/jdbc-select-database.htm
Be nice to find a tutorial on how to just manually make the database parameters outside of code.
The project is for university, they want me to create a client similar to MySpace. Have clients connect to a server, share music and message friends. I have done the UI and multi threaded server connections and understand how to read and write data to the UI or File. Just figured an SQL database would be the best way to store all this user data.
You just need to check the table Exist or not.
If the table exist then use it else create it and then you can use it.
So I'm creating a program that auto generates forms for data entry. The form is created by a user (its a simple table setup with the ability to merge cells). Some of the cells contain text views, others contain text inputs (all based on how the user draws it).
This form is then sent to another application that draws it back out. I was wondering what the best method is to represent the form. I though either use XML to represent the form or use a database that would basically function as a grid and row 1 column 1 in the database would match the form cell row 1 column 1 and so on (kind of an odd way to use a database).
The form creation program is made in C++ and the form regeneration program is created in Java.
Is there an even better way to do this?
Thanks,
I am also thinking the same thing because I am in to creating dynamic forms for my framework to. So I will share some thoughts with you. Using database to add new forms like adding a record in one table that specifies the form and its fields in another having the ability to select it's field types to, or creating one table for each form and each time create a new table or altering its fields (sound messy).. or create a folder with a bunch of xmls that are used for the structure of your forms?
When it comes to database:
Your application is stricted with a specific database application
like sql server 2008 or mysql or mysqli or oracle etc.
Your application is causing network traffic, not that bad but it is
doing it eveytime you need to create or use a form.
You need a panel that creates those forms using the database, and
can be accessed if its web even from your mobile.
When it comes to XML:
Your application is free from database version restrictions.
you need the impersonator to have the right to create files in a
spesific directory in your frameowork.
You don't need a panel even though you can create one, because XML are human readable files. So you can make one while eating your dinner and serve it to your system,
and wala, you have your form generated.
These are my thoughts for now.
How about the methods that will be used in the form? will those also be dynamic? How can you specify what calls what? this is also what you need to take in account.
I think that XML is a much better choice here. Using database as a grid could be more of a headache than needed. You will have to deal with all the problems related to having the database and not really get any benefits of the database. The industry decides to go with xml more often than not as well (xbrl being one example).