H2-使用SQL语句访问链接表时出错&SELECT*FROM NULL T&

2022-08-11 00:00:00 mysql java h2

我尝试在Java应用程序中创建链接表。

Statement stmtH2 = DBconnect.connH2.createStatement()
String linkedTable = ("CREATE LINKED TABLE tableName('', 'jdbc:mysql://localhost:3306/DBname', 'root', '', 'tableName');";
stmtH2.execute(linkedTable)

String query = "SELECT * FROM tableName WHERE Sex = 'F' ORDER BY Cod";
stmtH2.executeUpdate(query);

在Java中,我收到以下错误:

org.h2.jdbc.JdbcSQLException: Column "COD" not found; SQL statement:

当我尝试在运行SELECT * FROM tableName的本地主机:8082中查看表时,出现错误:

Error accessing linked table with SQL statement "SELECT * FROM null T", cause: "org.h2.jdbc.JdbcSQLException: Class ""com.mysql.jdbc.Driver"" not found [90086-175]"; SQL statement:
SELECT * FROM tableName [90111-175] 90111/90111 (Help)

为什么找不到列"COD"?


解决方案

您的应用程序丢失com.mysql.jdbc.Driver。将其添加到应用程序的类路径中。

相关文章