我正在尝试在Eclipse Luna和Windows 7下使用Sqlite,jdbc.
当我使用Sqlite数据库的绝对路径时,一切正常,但是当使用相对路径时,我收到此错误:
java.sql.SQLException:[SQLITE_ERROR] SQL错误或缺少数据库.
我花了一些时间谷歌搜索这个问题,答案是:是的你可以使用相对路径与jdbc连接.但它对我不起作用.
我的代码:
package PortiaMoxy;
import static net.mindview.util.Print.*;
String inPath; // incoming file
String outPath; // converted file from incoming file
public File() {
// Connect to Sqlite db
Connection c = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("org.sqlite.JDBC");
//
// This connection works fine
//
//c = DriverManager.getConnection("jdbc:sqlite:/JavaProjects/workspace/Polymorphism/sources/PortiaMoxy/moxyimport.sqlite");
//
// This connection doesn't work. ???
//
c = DriverManager.getConnection("jdbc:sqlite:moxyimport.sqlite");
c.setAutoCommit(false);
print("File(): Opened database successfully.");
stmt = c.createStatement();
String query …Run Code Online (Sandbox Code Playgroud) 我是百里香新手。最近我无意中遇到了以下情况。这是我的 Thymeleaf html 页面的一部分:
<!-- an delete button link -->
<a th:href="@{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ?') )) return false" >
Delete
</a>
Run Code Online (Sandbox Code Playgroud)
这段代码按预期工作得很好。不过,我想添加员工姓名作为确认的一部分。这是代码:
<!-- an delete button link -->
<a th:href="@{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ' + '\'+${tempEmployee.firstName}+\'' +'?' ) )) return false" >
Delete
</a>
Run Code Online (Sandbox Code Playgroud)
不幸的是结果是:
Are you sure you want to delete this employee
'+${tempEmployee.firstName}+'。
Thymeleaf …