I am currently training to be an application developer and am in my second month.
Now I got a task that felt impossible for me.
I have also googled since yesterday but did not find anything.
I have to insert the data from a database that I access with SQL Explorer into a .csv file. and save it on my machine
It should work automatically, but for testing it doesn't have to.
I use Eclipse and program with Java, have seen something on the Internet that it works with MySQL, but the DB2 database is connected with the SQL Explorer.
My plan is a solution, programming in java to update everyday the csv thats basically my task
Sorry if it doesn't fit here on Stackoverflow, I'm totally lost because I'm still in the trial period.
Greetings from Germany
IBM Data Server Client and driver types.
The IBM Data Server Driver Package, for example, contains the Command line processor plus utility which can run various db2 commands, statements and scripts including the Db2 EXPORT command.
Usage:
From the OS command line:
clpplus -nw user/password#host:port/database #s1.sql
The contents of the s1.sql file used as a parameter above:
SET ECHO ON;
EXPORT TO "full\path\to\my_file.csv" of del
SELECT *
FROM MYTABLE;
EXIT
You may use whatever valid SELECT statement in the EXPORT command.
Related
I have been searching for hours on how to backup the schema for my database through Netbeans 8.2 I just want to backup my work in the event of computer failure. I tried using command line but no resource is up to date yet on how to properly backup for windows 10 and Netbeans 8.2. Any solution would be greatly appreciated.
NetBeans does not offer this feature. You can only grab and recreate the structure of single tables (Under Services / Databases / [your database] / right click on any table). But this does not include any containing data.
Shashanth mentioned already some alternatives where I would like to add HeidiSQL which does an awesome job.
If you want to implement this as a feature in your own application you probably want to call mysqldump from your program (see this question in addition to the thread provided by Shashanth)
I've been given the unenviable task of updating someone else's 4 year old half-finished code in a language that I largely don't know.
Previously, a powershell script uploaded all records from Microsoft Access to Salesforce, which required juggling of various config files. This would be done once a month.
I have changed it to upload all records from the previous two days, and scheduled it to run once a day. Now it only uploads some of the data (the difference varies by 60-100 values depending on the table).
I am currently painstakingly comparing the values manually to see if anything is common with the Microsoft Access data and salesforce data.
This is the bit that does the uploading:
CMD /c "call ..\Java\bin\java.exe -Xms1024m -Xmx1256m -cp ..\dataloader-28.0.2-uber.jar -Dsalesforce.config.dir=.\config com.salesforce.dataloader.process.ProcessRunner process.name=Patients"
This bit is the bit that extracts Access data to csv:
Get-AccessData -sql "select * from $tables where DateReceived >= `#$firstDate`#" -connection $db | Export-Csv -Path $outcsv –notype
Also, the script doesn't work if I run it through the Powershell editor, but does work if I just run it through the batch file my predecessor has kindly left.
I have a Java program that uses MYSQL for the database. Every time I want to run the program I must ensure that the MySQL server is running so that JDBC can connect to my database. How can I package my program with a JDBC driver and a copy of MySQL so that it runs in other computers without having to expect the user to install and manually start MySQL separately? I wish to achieve this so that my program will be a portable program with everything correctly and automatically installed by my Java program. Thanks
It may be funny answer but as smart as question. Run Ubuntu from your pendrive. Connect external hdd/ssd. Use dd command to create image of your drive. Than swap your hdd and burn your *.img file to other drive. Then take copied drive to other computer and insert your drive. Than boot. Simpler solution is to use SQLite insted of MySQL.
I have finished writing a Java Desktop application with a mySQL database. I want to make the application run outside netbeans and let it be installed on other computers. I know about building the project and creating the runnable jar file, however this requires me to export the database itself to the other computer I want the application to run on.
My question is two parts:
1)Is there a way I can create a setup file that also installs the database and the application together?
2)Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Thanks
Yes. You can use some setup builder, like InnoSetup, for example. Personally, however, I like giving my customers a zip file, which they extract wherever they like. The executable jar should be able to handle everything by itself (I like it where there is no need to install the software, just unpack and run).
If it is hardcoded, then yes (but, what do you mean by hardcoded? path to file? ip address?). You should use properties or configuration files for paths and other external things your software depends on. The software should read from those files. Upon startup check for presence of such file(s) - if missing, the user should be shown a window in which the config can be entered.
As for deploying MySQL with your code - consider using a server for that, so that your users are not forced to install MySQL, instead they connect to it over the net. If you need the database only for storing data locally, why not using SQLite or a similar, file-based db engine?
The above answers are just suggestions and more-less reflect the way I am thinking. I would be happy to hear from someone with more experience. Nonetheless, I hope the answers help a little :)
I agree with Sorrow.
If I have to use MySQL, it is normally over the net since I don't want to allow my clients pass through the hazzles of installing MySQL themselves. If however you am stuck with using MySQL locally, investigate MySQL unattended installations + NSIS Installer.
If you can use any db you want, I just use javadb/derby. It comes bundled with most Java installations these days and if not all you need is to add a jar file to you application.
As per 'hardcoding' paths, I really don't understand what you mean. You really don't have 'paths' as it were, I am assuming what you mean is connection string. You don't have to hardcode your connection string, just put some parameters in a properties file and construct your connection string from them.
1) Is there a way I can create a setup file that also installs the database and the application together?
See my answer to Java based Standalone application.
2) Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Have the DB installer pop a JFileChooser to ask the user where they want to install the DB. Store that path using the JNLP API PersistenceService. Here is my demo. of the PersistenceService.
I want to run a .sql file from java without using jdbc on windows 7. I am trying with java runtime class which executes the system commands. But my java is running with only user privileges and the command needs Administrator privileges. The command that am using to run is "sqlplus /nolog #sqlscript.sql".
You need either JDBC, or a 3rd party software+sufficient rights.
No other way. (If we don't count low-level DB access, which would be an overkill)
I was able to do it by installing oracle client as the logged in user(We need to hold the shift key and right click on the exe and select Run as different user). Also we need to set oracle home in non primary partition of the hard diski.e., not where OS is installed. After doing this if i pass a command like "sqlplus /nolog #test.sql" to the Java Runtime class, it executes the script. This works in only win 7 Ultimate and above. Win 7 Home and starter editions does not support this.