[英]how to connect client computer to use Sqlite database which is installed in the server computer using java programming?
I am developing a commercial desktop application using java Programming Language and i am using Sqlite as my database of choice. 我正在使用Java编程语言开发商业桌面应用程序,并且正在使用Sqlite作为我选择的数据库。 But in a situation whereby i want this software to be install to two or more client computer and my wish is that the client computer installed software should make use of server computer software Sqlite database(one common database).
但是在一种情况下,我希望将此软件安装到两个或更多客户端计算机上,而我的愿望是,客户端计算机安装的软件应使用服务器计算机软件Sqlite数据库(一个公共数据库)。 My Questions are: What are the proper procedures to achieve this using Networking and java?
我的问题是:使用Networking和Java实现此目的的正确程序是什么? and What is the proper connection strings to apply to the client and server computers ?
以及适用于客户端和服务器计算机的正确连接字符串是什么?
Below is my server connection that works for me: 以下是适用于我的服务器连接:
import java.sql.*;
import javax.swing.JOptionPane;
public class dbconnection {
Connection conn = null;
public static Connection ConnectDB() {
Statement stmt = null;
try
{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:myDatabase.sqlite");
System.out.println("Connected database successfully...");
return conn;
}
catch(Exception e)
{
System.out.println("Exception 1: "+ e);
return null;
}
}
}
Thanks so much!!, As you provide solution for me. 非常感谢!,当您为我提供解决方案时。
From when to use SQLite : 从何时使用SQLite :
SQLite strives to provide local data storage for individual applications and devices.
SQLite致力于为单个应用程序和设备提供本地数据存储。
If you want to implement some kind of client/server architecture using SQLite you can achive it like (source: serverside database ) 如果您想使用SQLite实现某种类型的客户端/服务器体系结构,则可以实现它(来源: 服务器端数据库 )
Server-side database
服务器端数据库
Systems designers report success using SQLite as a data store on server applications running in the datacenter, or in other words, using SQLite as the underlying storage engine for an application-specific database server.系统设计人员报告说,使用SQLite作为在数据中心中运行的服务器应用程序上的数据存储,或者换句话说,使用SQLite作为特定于应用程序的数据库服务器的基础存储引擎,已经取得了成功。
With this pattern, the overall system is still client/server: clients send requests to the server and get back replies over the network.使用这种模式,整个系统仍然是客户端/服务器:客户端将请求发送到服务器,并通过网络获得回复。 But instead of sending generic SQL and getting back raw table content, the client requests and server responses are high-level and application-specific.
但是,客户端请求和服务器响应不是高层SQL而是特定于应用程序,而不是发送通用SQL并获取原始表内容。 The server translates requests into multiple SQL queries, gathers the results, does post-processing, filtering, and analysis, then constructs a high-level reply containing only the essential information.
服务器将请求转换为多个SQL查询,收集结果,进行后处理,过滤和分析,然后构造仅包含基本信息的高级答复。
Developers report that SQLite is often faster than a client/server SQL database engine in this scenario.开发人员报告说,在这种情况下,SQLite通常比客户端/服务器SQL数据库引擎更快。 Database requests are serialized by the server, so concurrency is not an issue.
数据库请求由服务器序列化,因此并发不是问题。 Concurrency is also improved by "database sharding": using separate database files for different subdomains.
通过“数据库分片”还可以提高并发性:针对不同的子域使用单独的数据库文件。 For example, the server might have a separate SQLite database for each user, so that the server can handle hundreds or thousands of simultaneous connections, but each SQLite database is only used by one connection.
例如,服务器可能为每个用户有一个单独的SQLite数据库,因此服务器可以处理数百或数千个同时连接,但是每个SQLite数据库仅由一个连接使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.