Hi, I'm wondering if it's possible to have a desktop app with a database online?
Can you give me an example? :P
Hi, I'm wondering if it's possible to have a desktop app with a database online?
Can you give me an example? :P
Yes, you can. But choose the architecture carefully. For a desktop app, the safest and most maintainable approach is what and @hfx642 hint at: put a small service in front of the database (REST/gRPC on an app server), keep the DB on a private network, and let the desktop talk HTTPS to that service. You gain proper auth, validation, and connection pooling, and you avoid exposing SQL to the public internet. As said, if the DB is on your LAN a URL change often works; across the internet, use a VPN or SSH tunnel at minimum.
If you still need direct JDBC to a MySQL server you control, lock it down and use TLS. Minimal example:
import java.sql.*;
String url = "jdbc:mysql://db.example.com:3306/appdb?sslMode=VERIFY_IDENTITY";
try (Connection con = DriverManager.getConnection(
url, "app_user", System.getenv("APP_DB_PASS"));
PreparedStatement ps = con.prepareStatement(
"SELECT id, name FROM customer WHERE email = ?")) {
ps.setString(1, "alice@example.com");
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) { /* use data */ }
}
} Quick checklist to make this reliable and safe:
Good luck . And , these steps should get you connected if you still want to try direct JDBC.
Jump to Post— Member #647493It's called a "Client Server" database system (or 2 tiered).
But, that's the OLD way to do it.
Now, everything should be done through a browser.
The application is online on an Application Server
and the database is also online.
Browser, Application Server, backend. (3 tiered)
Jump to Post— peter_budo 2,532I have had this same question. Though I could not figure out how to get it to work you use Mysql and JDBC to make an online database on a server. you then connect to the server and write, or read from the database. please message me if you figure …
It's called a "Client Server" database system (or 2 tiered).
But, that's the OLD way to do it.
Now, everything should be done through a browser.
The application is online on an Application Server
and the database is also online.
Browser, Application Server, backend. (3 tiered)
I have had this same question. Though I could not figure out how to get it to work you use Mysql and JDBC to make an online database on a server. you then connect to the server and write, or read from the database. please message me if you figure it out.
I have had this same question. Though I could not figure out how to get it to work you use Mysql and JDBC to make an online database on a server. you then connect to the server and write, or read from the database. please message me if you figure it out.
1) You can have DB enabled to receive connection from other sources then localhost which is default setup on most database instalations
2) You can provide service to which your desktop application will send request, this processed and DB queried, afteer that respond is generated and forwarded to client (your desktop application). This is commonly described as web service (The Java Web Services Tutorial)
Thanks for the replies. So basically, it's not just as simple as changing the url that I use when I connect to my database on my pc?
And also thanks for the tutorial link. If you have other references for solving my problem, please share it to me. thanks! :)
1. The answer is "Yes."
>;->
2. If the database is on your local LAN, rather than accessed through the Internet, then you generally can access it just by changing the URL that you use.
3. Connecting from a desktop application through the Internet to a database is generally a bad idea, for both performance and security reasons.
Using web services, as peter_budo suggested above, is generally the best answer for business applications.
For a quick and dirty development-time workaround, consider Virtual Private Network (VPN) tunneling.
There are vendor products to do JDBC on a client against a server database (http://www.idssoftware.com/jdbchttps.html), but be aware of performance and security issues: Secure sockets from an untrusted client PC does not protect you from hackers! If the client boxes are "trusted," then you may as well put them on the LAN, via VPN if appropriate.
Hi every how to create text editor in java app
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.