Simulate JDBC data source - java

I am attempting to simulate a JDBC 3 compliant data source.
I have a legacy java application that only accepts JDBC data sources and cannot be changed. I would like it to be able to use data from a provided JSON file and convert it into some type of source that can be connected to using JDBC. It is impossible to change or access the legacy java application source code, and the application requires data to be retrieved through a JDBC connection.
Is this possible?
At the moment the only solution I can think of is to import the JSON file into a SQL database and then connect to that. I would like to avoid this because the JSON file is originally generated from a database and provided through a web service. I cannot connect to the original database.

Related

Can I use Neo4j BI Connector with my Java app?

Neo4j have recently added a BI connector tool (neo4j.com/bi-connector) which can return relational data from your graph database to your business intelligence tool such as Tableau. The question is can i send SQL queries to this connector assuming i have added the jar file to my java application class path? If yes, which APIs should i use to send this SQL query to the driver?
I'm using Neo4j4.0.
For neo4j.com/bi-connector, if you look at the document PDF that you get when you download it, on page 10 where they show how to establish a connection you'll see that you get a connection object. After you have that, you have a standard JDBC connection which is a Java interface that tells libraries how to talk to a SQL database. There are a lot of different tools that use this interface, it's kind of user preference. A common one is JOOQ.

Java Eclipse Connect to MySQL via Tomcat

How to connect Tomcat9 to a MySQL database and access the database in eclipse using Vaadin14? I already pasted the mysql connector in the tomcat\lib directory. Is there anything else to do/change?
Afterwards i created a ui that contains a few text fields and a java class car with some attributes and the corresponding getters/setters. I bound the text fields to the attributes using a binder. In my database there is also a table car with the same attributes and some entries.
So how do i connect the database to my project in order to show one of the entries in my text fields and create a new entry?
Sorry if this is basic java/vaadin, but i'm quite new to databases.
So how do i connect the database to my project in order to show one of the entries in my text fields and create a new entry
You first need to connect to a database. It depends on your project, how you implement it. (via Spring, for example). A good discussion on this topic is here: Connect Java to a MySQL database
and some documentation here Connecting to MySQL Using the JDBC DriverManager Interface
Then you read data you need from a database. You can use ORM such as Hibernate or use a JDBC package as this. A discussion on pros/cons can be found here: What Java ORM do you prefer, and why?
Once you have your data available, you can bind an object to the binder (if you use one) or using setValue for the fields. There is an example for Vaadin 8 here : Building a web UI for MySQL databases (in plain Java), but it should be applicable with a Vaadin 14 as well. (Or what is your version?)
You could also check a bakery starter and how connection/reading is implemented there.
Some other useful links on topic:
What is JPA? Introduction to the Java Persistence API
Vaadin app with MySQL database

PostgreSQL JDBC driver with data encryption

Do you know whether PostgreSQL JDBC driver with on-the-fly data encryption exists?
I use PostgreSQL database on Heroku and have requirement to encrypt some sensitive client data on database level. How it's possible to implement this?
Heroku allows to use PostgreSQL pgcrypto module but it allows only per-column encryption and work with the module looks cumbersome. So I'm thinking about data encryption on Java side.
JDBC driver irrelevant to encrypted storage
For encrypting data “at rest”, that is, when written to storage, the JDBC driver is irrelevant.
A JDBC driver’s job is to mediate between a Java app with Java types and a database with database types. The driver communicates with the database, relying your queries, and then marshaling back the results. The driver converts data between the types used on either side.
The JDBC driver does not affect how the data is stored by the database.

Flex connection with database

I need to write values from form in flex to an oracle database. I know i will be using the blaze DS bridge but I can not understand how to send all the parameters at once to my java class which connects to the database. I have established the connection and I am being able retrieve values from java to flex but not vice versa. Can someone help.
Download Blazeds turnkey server from the site.
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS
In tomcat\webapps\samples\WEB-INF\flex-src
Extract flex-src see the sample testdrive-update.

how to place database on remote server using android

I am devloping an android application using java.now i want to place db on remote server,and want to access and upgrade the database.
Can anyone help me?
It's at least a challenge to write an android application that would be able to talk with a remote database. AFAIK, there's no jdbc on android.
So your "remote database" needs an additional business layer, some sort of public API that you can use for your CRUD operations. Otherwise you'd have to port jdbc and a jdbc driver for you database for android...
A very simple (and pretty dangerous!) API would simply accept SQL strings (from a trusted source!), forward this SQL to the database and respond with the result set (csv format, for example).
Typically, you won't allow remote connections to your db from an untrusted source.
Instead, think about what operations you want to execute on the database. Then write an interface with all the required methods (addEntry, removeEntry, etc).
On the client side (android), create a class that implements this interface by delegating to the server (HTTP requests or whatsoever).
On the server side, implement the same interface with JDBC access to your db and set up a simple server process that delegates the requests (HTTP or whatever) to this implementation. That's it.

Categories

Resources