【问题标题】:java.sql.SQLException: Unable to find a suitable driver for jdbc weka.experiment.DatabaseUtils.connectToDatabase(DatabaseUtils.java:563)java.sql.SQLException:无法为 jdbc weka.experiment.DatabaseUtils.connectToDatabase 找到合适的驱动程序(DatabaseUtils.java:563)
【发布时间】:2017-11-09 13:22:44
【问题描述】:

我正在尝试通过 weka 实验检索实例查询将 Weka 连接到 MS SQL DB 并收到以下错误

这里要注意的一点是我没有为 MS SQL 数据库实例分配任何默认端口,下面是我的 Databaseutil.props 文件内容

# database URL
jdbcURL=jdbc:sqlserver://MSSQL\SQLEXPRESS;databaseName=MovieDatabase
# specific data types
string, getString() = 0;    
boolean, getBoolean() = 1;
double, getDouble() = 2;  
byte, getByte() = 3;      
short, getByte()= 4;      
int, getInteger() = 5;    
long, getLong() = 6;      
float, getFloat() = 7;    
date, getDate() = 8;      
text, getString() = 9;    
time, getTime() = 10;     
timestamp, getTime() = 11;

# map SQL Server data type to WEKA data type
# default mappings
varchar=0
float=2
tinyint=3
int=5
# values added manually
string=0
bigint=6
nvarchar=9
decimal=2
bit=1

错误:

sql.SQLException: 无法为 jdbc 找到合适的驱动程序:sqlserver://MSSQL\sqlexpress:1433;authentication=NotSpecified;authenticationScheme=nativeAuthentication;xopenStates=false;sendTimeAsDatetime=true;trustServerCertificate=false;TransparentNetworkIPResolution=true; serverNameAsACE=false;sendStringParametersAsUnicode=true;selectMethod=direct;responseBuffering=adaptive;packetSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCount=true;encrypt=false;disableStatementPooling=true;databaseName=MovieDatabase;columnEncryptionSetting =Disabled;applicationName=Microsoft JDBC Driver for SQL Server;applicationIntent=readwrite;
weka.experiment.DatabaseUtils.connectToDatabase(DatabaseUtils.java:563)
weka.experiment.InstanceQuery.retrieveInstances(InstanceQuery.java:658)

【问题讨论】:

  • 您的类路径中是否有适合 MS SQL Server 的驱动程序?我不知道 Weka 是如何启动的,但我认为您需要一些 JDBC 驱动程序 jar 存在于运行时类路径中才能使其工作。类似jtds.sourceforge.net
  • 是的,我已将 Microsoft 的 sqljdbc42.jar 添加到类路径中。我看到端口号 1433 正在附加,这不是我的连接所必需的,有什么想法吗?
  • 您可能需要加载驱动程序类才能将其注册到驱动程序管理器。您能否向您的应用程序添加一些代码(尽快...在尝试加载 JDBC 驱动程序之前):Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  • 好吧……再想想。根据这个(weka.wikispaces.com/databases),您应该将 jdbcDriver 属性添加到您的配置文件中。因此,请尝试将 jdbcDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver 添加到您的 Databaseutil.props 文件中。
  • 还有...根据上面的文档,你的 props 文件应该命名为 DatabaseUtils.props

标签: sql-server jdbc weka


【解决方案1】:

我在我的环境中遇到了同样的问题。从依赖项中删除范围后(最初我进行了测试),它可以工作。

【讨论】:

    【解决方案2】:

    尝试将 jdbcDriver 属性添加到您的 DatabaseUtils.props 文件中:

    jdbcDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2013-09-06
      • 1970-01-01
      • 2013-07-04
      • 2023-03-18
      • 2016-11-28
      • 2011-08-02
      相关资源
      最近更新 更多