How to access different SQLite database (schema) using JDBC - java

I have an application that uses an Oracle database. It reads data out of the database using statements like:
SELECT * from schema.table WHERE ...
I would like to create a SQLite database with data I can use for regression-testing the application. It's simple enough to change the jdbc settings to get the application to connect to a different database, but the SQL statements need to be exactly the same.
I know when I run SQLite from the command line, I can attach a database using
attach database as
If I do that, then the same select statements that work in oracle to access a table in a different Oracle schema will work to access the data in a different SQLite database. But, since I'm connecting via JDBC, I don't have the option to run the "attach database" command.
Is there a way to configure SQLite such that it will accept requests like the above?
I tried
create table "schema.table" ...
That worked, but then I need to include the quotes in the select statement, which Oracle won't allow.

Related

Not able to select table, but able to see all table in mysql

I spinned up a new RDS mysql instance on aws. I run different script and was able to create table.I can see the table in workbench and other clients like sql developer but when I run a query it is say table doesn't exist.
My database is testdatabase.
i created table called user. I am able to see in browser and export the data as well. But when I run
use testdatabase
select * from user
SQL Error (1146): Table 'testdatabase.user' doesn't exist
It say table does not exist. I searched all forums, I did not export a database or restored from backup. I have admin privilege what need to be done?I created a new database and created tables using scripts.

Inspect or Visualize in memory database created using sqlite jdbc during debug

I am creating a temporary sqlite jdbc database structure in memory.
Somehitng like this,
Connection connection = DriverManager.getConnection("jdbc:sqlite::memory:");
However, it would be really nice to be able to see/visualize this database while debugging.
I have created a complete set of database and can retrieve this data using ResultSet and Statement.executeQuery("Query");
Any ideas, how can it be achieved in Netbeans debugger.
In-memory databases cannot be accessed from another connection.
For debugging, create a database in a file.

use existing sqlite database in java webapp

I have a java web app. I need to point to an existing sqlite database that I have in the project root (in eclipse).
I have all of the required drivers/jars.
The problem is that code to select from my sqlite database tables runs against a newly created database. I get an error that my table "Table1" doesn't exist. I believe this is because a new database is being created as opposed to using the existing sqlite database in the root with the tables and data that I need.
Does anyone know how I can force this local sqlite database to be used?
Per the SQLite docs, a new database will be created by default if it doesn't find an existing one -- so the most likely explanation is that the path in your connection string isn't pointing to your pre-existing database.
See the question here about relative paths in web apps: if your web-app is a servlet, use ServletContext.getResource to get the path to your database to use in the connection string. So, if your existing database is in /WEB-INF:
ServletContext.getResource("/WEB-INF/my.db");

How to update android database by connecting to a remote location

Im looking to connect to a URL and download a file (.db) and if it is of a higher version then update the database on the app. e.g. currently using Database1.db and this online one is Database2.db. However I'm not really sure how to go about this. Im using sqlite.
Thanks
From server end:
Instead of uploading database from url you can post xml or json data
which will give details bout database version and sql query
From android program
connect to url get the data check for the version if version from url
is higher than that of existing one then execute the sql query that
you got to create database and take backup of your data
Scenario
Lets consider one scenario you have some data in a table named y in
old database. but the new database which you are downloading doesn't
have that y table but it has some new table then what do you want to
perform with that data. Do you want to discard or store if store and
use then to where you want to store.

Java bridge between PHP and Database

First, I will present what it is doing my web-application :
The subject of this web-application is different distributed databases and distributed data sistems with a specific type of information. Until now I programed using PHP, JavaScript and JQuery-ui. For databases I used MySQL and PostgreSQL and I thinking to use and Oracle. On short way on my web application the user firstly have to register. If he is accepted by Admin then he have the possiblities :
Connect to HIS database (MySQL, Oracle, Access, PostgreSQL)
Run queries between two, different or not, databases
To connect to his database the user enter information like : host, user, password and name of database. At next step he can see the tables from database. If he select one line he will be able to Update, Create and Delete the content from the selected table.
On this section the user can look for similarities between the two databases (with key words or structures of tables) : one that belongs to him and another one that belongs to the Admin.
I use WampServer, version 2.1 with Apache/2.2.17 and PHP/5.3.5 and I want to do a bridge who will be responsable with the connection to the databases and in which I will comunicate with different databases. The informations from interface will be sent as MySQL queries and in the bridge I will adapt that queries for each type of database.
Can someone to help me ?
Soon as possible.
Thank you !
Simon
The informations from interface will
be sent as MySQL queries and in the
bridge I will adapt that queries for
each type of database.
This is a very bad idea for two serious reasons:
To implement it, you'd have to write your own SQL parser.
Each major database implements its own dialect of SQL, which means you'll have to know how to translate between their specific syntax and command sets.

Categories

Resources