Create MySql Database using Matlab - java

I am using Database toolbox of Matlab to run my MySQL queries. I am doing this by using JDBC driver (Connector/J).
I am able to connect/create/delete new tables for a given database.
Is there a way by which I can directly create a new database from Matlab itself? I'm looking for a solution which lets me do this by using the toolbox or by using Java from Matlab.

Here's what I have used. In Matlab this works.
import java.sql.*;
ConnD = DriverManager.getConnection(...
'jdbc:mysql://localhost/?user=urname&password=urpassword');
sD=ConnD.createStatement();
Result=sD.executeUpdate('CREATE DATABASE urdatabasename');
sD.close();
ConnD.close();
Mind you, this doesn't include error handling and checks. Make sure you handle your data carefully.

Related

Accessing Connected Database DB in Eclipse with Java Code

I successfully connected to a DB in eclipse through the Database Development perspective and am able to run queries in the SQL File Editor. However, I would like to write java code to automatically run a query and then extract the data to a flat file. What is the easiest way to do this? Since I am already connected to the database, can I bypass the java code that involves connecting to the database.
No, the Java JVM also needs to be able to connect to the database. There are many examples of JDBC connections on the internet, including this one.
Once you have got the data you needed, you should make use of FileWriter in order to write the information to file.

Java sql like sqlite

I created an android app. and I used sqlite to keep my small files. When I use sqlite, I could create tables, and did operations with just a java class.
Now I am creating pure java application, and I need small database that can be created with programmatically on java application like android sqlite.
Is there any java database like sqlite ?
You can still use Sqlite, also you could use H2 which has similar features.

Export oracle database data through java code

I'm using Oracle Database 11g Express Edition to set up my database. The way I currently backup my database data is through SQL Developer. (Right click on tablename > export)
Which will give me a .sql file.
But, how do I do this through java code? I've looked into expdp, but I don't know how to execute it through my code, if that's even the right way to do it.
Can someone help me out here?
Data Pump can be automated through the standard package DBMS_DATAPUMP. You could build a small PL/SQL procedure and call that procedure from Java. Here is an example of exporting a schema with DBMS_DATAPUMP, but it does not look very intuitive.

How to install SQLite database on the WIndows XP system

I want to connect my java program to the SQLite db. What are necessary steps that I have to follow. I want to install sqlite database on my system to access the database.
From the SQLite Homepage:
SQLite is a in-process library that implements a self-contained,
serverless, zero-configuration, transactional SQL database engine.
[...]
SQLite is an embedded SQL database engine. Unlike most other SQL
databases, SQLite does not have a separate server process. SQLite
reads and writes directly to ordinary disk files. A complete SQL
database with multiple tables, indices, triggers, and views, is
contained in a single disk file.
So you don't actually install SQLite. To create and work with SQLite Databases, you can use the provided sqlite-shell, which is a command-line tool. If you are familiar with SQL, this should not be a problem.
Although, there are also some GUI-tools out there to work with SQLite...
If you want your Java-application to access and work with an SQLite Database, you'll need the necessary drivers. A nice topic on this can be found here.
Hello mayur rahatekar,
Here's a quick tutorial for creating a sqlitedb on your computer, its explained from the ground of:
SQLiteDB with some Androidflavour
Best Regards
safari
You can take the help of mozilla firefox browser.If you have then you can search on google how to integrate sqlite with mozilla.it's very easy.Click here to see the link.

Setting up sqlite database

Sorry I am a noob, I am trying to learn about sqlite databases using linux, I cannot find any tutorial that covers what I need from setup to creating to using. At the moment tutorials I find say open a shell using adb shell command but when I open a terminal this does not work even if I navigate to the android tools folder, I can get the sqlite command working but the tutorials dont explain how I use it. For instance, how do I store urls and map coordinates and how to I reference them.
I have tried to use the firefox plugin but I havent got a clue what it all means and every tutorial says sqlite database is easy but it seems so complicated.......HELP!!!!
P.S would it be possible to create the data within the application code, I have seen some apps that do this
Does anyone have a set up guide and tutorial that can help?
Take a look here: http://developer.android.com/guide/topics/data/data-storage.html#db
You should use a custom class extending SQLiteOpenHelper: http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html
It gives you methods like onCreate, onOpen and onUpgrade which are very useful.
To set up your database :
The recommended method to create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method, in which you can execute a SQLite command to create tables in the database.
To use it :
You can execute SQLite queries using the SQLiteDatabase query() methods, which accept various query parameters, such as the table to query, the projection, selection, columns, grouping, and others. For complex queries, such as those that require column aliases, you should use SQLiteQueryBuilder, which provides several convienent methods for building queries.
Resources :
developer.android.com - Data Storage
Are you using Java.
You can have a look http://www.zentus.com/sqlitejdbc/
Android has a class named SqliteOpenHelper using which you can create and communicate(do read / write operations) on sqlite using java. You can find many samples once you start searching in net. Here is one such sample.
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
If you want to open your database you can use Sqlite Manager which is available with Firefox as a Addon. It has a easy interface so that you can load your database directly and check .
If you are planning to create a new SQLite database then over ride and implement the onCreate() Method.
But if you are using a SQLite database that is created by another external source and you are going to pull it down, then leave the onCreate() method empty.
You might look at SQLite Manager, which is a free GUI and available in a Linux variety. I highly recommend it.

Categories

Resources