简体   繁体   English

如何使用Java编程连接客户端计算机以使用安装在服务器计算机中的Sqlite数据库?

[英]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.

相关问题 如何使Java客户端使用套接字连接到不在我的计算机上的服务器? - How to make a java client use a socket to connect to a server not on my computer? 如何连接到运行Java服务器的另一台计算机? - How to connect to a different computer running a Java server? 如何使用Java访问我的计算机(相距50公里)中的另一台计算机mysql数据库 - How to access another computer mysql database in my computer(which is 50km away)using java 如何在Java中使用可在任何计算机上运行的数据库 - how to use database in java that will work on any computer 服务器如何知道客户端的端口号,它将使用它使用 Java 编程套接字将响应发送到客户端? - How the server knows the port number of the client in which it will use it to send the responses to the client using java programming socket? 使用一台计算机在 java 中多次连接到服务器 - Connect to a server multiple times in java using one computer 如何使用Java SQL连接器连接到另一台计算机上的数据库 - How can the java SQL connector be used to connect to a database on a different computer 如何使用Java将客户端系统的属性发送到服务器计算机? - How to send client system's properties to server computer in java? 如何从服务器在客户端计算机中执行Java应用程序? - how to execute a java application in a client computer from a server? 获取计算机上使用 Java 安装的软件列表 - Getting the list of softwares installed using Java on a computer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM