java连接Sqlite URL怎么写

大_爱 2013-01-04 04:43:25
想用java连接远程的Sqlite数据库,不知道url怎么写 ,连接本机的倒是知道怎么写

connection = DriverManager.getConnection("jdbc:sqlite:");


getConnection("");中怎么写啊?
...全文
592 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
大_爱 2013-01-04
  • 打赏
  • 举报
回复
有人不啦。
大_爱 2013-01-04
  • 打赏
  • 举报
回复
我想连接mysql那种连接sqlite。跟上IP然后跟上端口,写上数据库名称就可以了
大_爱 2013-01-04
  • 打赏
  • 举报
回复
引用 7 楼 suciver 的回复:
远程的话可以使用JNDI或者他那边如果有开端口的话可以用他的ip和端口
具体怎么做啦?
suciver 2013-01-04
  • 打赏
  • 举报
回复
远程的话可以使用JNDI或者他那边如果有开端口的话可以用他的ip和端口
大_爱 2013-01-04
  • 打赏
  • 举报
回复
大_爱 2013-01-04
  • 打赏
  • 举报
回复
Sqlite是安装在嵌入式设备上面的, 端口其实我是不知道的, 但是用ping能ping通 不知道这种怎么连接
大_爱 2013-01-04
  • 打赏
  • 举报
回复
引用 2 楼 fangmingshijie 的回复:
远程用Naming.lookup()
能说的详细一点吗?
  • 打赏
  • 举报
回复
远程用Naming.lookup()
大_爱 2013-01-04
  • 打赏
  • 举报
回复
有木有人啊?
Java连接SQLite数据库 一、下载SQLite数据库的JDBC:http://www.zentus.com/sqlitejdbc/ 二、将下载到的包解压后得到jar包放到%JAVA_HOME%\lib下,并且将其添加到ClassPath系统环境变量中。一定要保证在类路径ClassPath中有该jar包,并且保证在JAVA库路径JAVA Library Path中有本地库Native Library(\workspace\"Web应用"\WebRoot\WEB-INF\lib\下最好也要加入该jar包)。"SQLite.JDBCDriver"作为JDBC的驱动程序类名。连接JDBC的URL格式为jdbc:sqlite:/path。这里的path为指定到SQLite数据库文件的路径,例如: jdbc:sqlite://dirA/dirB/dbfile jdbc:sqlite://DRIVE:/dirA/dirB/dbfile jdbc:sqlite://COMPUTERNAME/shareA/dirB/dbfile 三、下面是使用SQLite的两段代码以供参考: 代码段1: 1 import java.sql.*; 2 import org.sqlite.JDBC; 3 4 public class SQLiteTest { 5 public static void main(String[] args) { 6 try { 7 // The SQLite (3.3.8) Database File 8 // This database has one table (pmp_countries) with 3 columns (country_id, country_code, country_name) 9 // It has like 237 records of all the countries I could think of. 10 String fileName = "c:/pmp.db"; 11 // Driver to Use 12 // http://www.zentus.com/sqlitejdbc/index.html 13 Class.forName("org.sqlite.JDBC"); 14 // Create Connection Object to SQLite Database 15 // If you want to only create a database in memory, exclude the +fileName 16 Connection conn = DriverManager.getConnection("jdbc:sqlite:"+fileName); 17 // Create a Statement object for the database connection, dunno what this stuff does though. 18 Statement stmt = conn.createStatement(); 19 // Create a result set object for the statement 20 ResultSet rs = stmt.executeQuery("SELECT * FROM pmp_countries ORDER BY country_name ASC"); 21 // Iterate the result set, printing each column 22 // if the column was an int, we could do rs.getInt(column name here) as well, etc. 23 while (rs.next()) { 24 String id = rs.getString("country_id"); // Column 1 25 String code = rs.getString("country_code"); //

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧