需要验证文本框中输入的数据为:
如何验证?
我的脑海中存在一个误解,认为 jdbc:sqlite: 会在安装应用程序的同一文件夹中自动创建数据库文件。但是,安装任何应用程序的文件夹都受到写保护。以下对我有用:
public static Connection getConnection() {
Connection conn = null;
try{
File theDir = new File( "c://spm_database");
if (!theDir.exists()){
theDir.mkdirs();
}
System.out.println(theDir.toString());
String dbpath = theDir.toString()+"/patientdata.db";
System.out.println("Current absolute dbpath is: " + dbpath);
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:"+dbpath);
System.out.println("data base connection established: "+ conn.toString());
// extra code .....
}
catch(Exception e){
}
retrun conn
}