为什么我无法获得 org.h2.Driver?我使用专家
我遇到了有关连接到 H2 的问题
这是我的pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>.</groupId>
<artifactId>dbConnection</artifactId>
<name>Db Connection</name>
<packaging>war</packaging>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.176</version>
</dependency>
</dependencies>
</project>
这是我的主代码
import java.sql.*;
public class DbConnection
{
static final String DB_URL = "jdbc:h2:tcp://localhost/~/test;AUTO_SERVER=TRUE";
public static void main(String[] args) throws Exception
{
try
{
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection(DB_URL,"sa","");
conn.close();
}
catch(ClassNotFoundException ex)
{
System.out.println( "ERROR: Class not found: " + ex.getMessage());
}
}
}
总是显示类未找到:org.h2.Driver