cobar-driver使用出问题!
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Class.forName("com.alibaba.cobar.jdbc.Driver");
String url = "jdbc:cobar://host:8066/database";
Properties info = new Properties();
info.setProperty("user", "root");
info.setProperty("password", "654321");
Connection connection = null;
try {
connection = DriverManager.getConnection(url, info);
Statement stmt = (Statement) connection.createStatement();
String query = "SELECT COUNT(*) FROM table";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
System.out.println("总数:" + rs.getString(1));
}
rs.close();
stmt.close();
} finally {
if (connection != null) {
connection.close();
}
}
我把cobar-driver包导进去,用上面的代码提示下面的错误:
java.sql.SQLException: No suitable driver found for jdbc:cobar://xxxx:8066/database
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.demo.cobar.CobarTest.main(CobarTest.java:21)
这种情况如何结局啊?
Contributor guide
Research direction
Start at CobarTest.java line 21 and verify how com.alibaba.cobar.jdbc.Driver is loaded alongside the cobar-driver dependency. Reproduce the jdbc:cobar:// connection attempt and determine why DriverManager reports no suitable driver; done means the sample connection succeeds or the required setup is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100