WEKA:java.lang.IllegalArgumentException:未知数据类型:int4
WEKA: java.lang.IllegalArgumentException: Unknown data type: int4
我正在尝试将我的 postgresql
数据库连接到 Eclipse
中的 WEKA
。
当我 运行 主要我得到这个 exception
:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown data type: int4. Add entry in weka/experiment/DatabaseUtils.props.
If the type contains blanks, either escape them with a backslash or use underscores instead of blanks.
- 我下载了 WEKA 3-6-14
- 我解压了 weka.jar
- 我在 weka/experiment/DatabaseUtils.props.postgresql
文件中更改了 jdbc url 和 jdbc 驱动程序的行
- 我添加了我在数据库中使用的数据类型
- 我将 DatabaseUtils.props.postgresql 文件重命名为 DatabaseUtils.props
这是我的 DatabaseUtils 的一部分。props.postgresql 文件:
# Database settings for PostgreSQL 7.4
#
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# url: http://www.postgresql.org/
# jdbc: http://jdbc.postgresql.org/
# author: Fracpete (fracpete at waikato dot ac dot nz)
# version: $Revision: 11887 $
# JDBC driver (comma-separated list)
jdbcDriver=org.postgresql.Driver
# database URL
jdbcURL=jdbc:postgresql://localhost:5432/datamining
# specific data types
string, getString() = 0; --> nominal
boolean, getBoolean() = 1; --> nominal
double, getDouble() = 2; --> numeric
# byte, getByte() = 3; --> numeric
# short, getByte()= 4; --> numeric
int, getInteger() = 5; --> numeric
# long, getLong() = 6; --> numeric
# float, getFloat() = 7; --> numeric
# date, getDate() = 8; --> date
# text, getString() = 9; --> string
# time, getTime() = 10; --> date
# timestamp, getTime() = 11; --> date
# PostgreSQL data types to Java classes information can be found at:
# http://www.postgresql.org/message-id/AANLkTinsk4rwT7v-751bwQkgTN1rkA=8uE-jk69nape-@mail.gmail.com
text=0
boolean=1
double=2
int4=5
这是我的主要方法中的代码:
InstanceQuery query = new InstanceQuery();
query.setUsername("username");
query.setPassword("password");
query.setQuery("SELECT * FROM database ORDER BY \"id\"");
Instances data = query.retrieveInstances();
有人可以告诉我为什么我仍然收到异常吗?
尝试将 getter 添加到 DatabaseUtils.props.postgresql
中的 int4
我将 DatabaseUtils.props 代码更改为:
# Database settings for PostgreSQL 7.4
#
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# url: http://www.postgresql.org/
# jdbc: http://jdbc.postgresql.org/
# author: Fracpete (fracpete at waikato dot ac dot nz)
# version: $Revision: 11885 $
# JDBC driver (comma-separated list)
jdbcDriver=org.postgresql.Driver
# database URL
jdbcURL=jdbc:postgresql://localhost:5432/datamining
# specific data types
# string, getString() = 0; --> nominal
# boolean, getBoolean() = 1; --> nominal
# double, getDouble() = 2; --> numeric
# byte, getByte() = 3; --> numeric
# short, getByte()= 4; --> numeric
# int, getInteger() = 5; --> numeric
# long, getLong() = 6; --> numeric
# float, getFloat() = 7; --> numeric
# date, getDate() = 8; --> date
# text, getString() = 9; --> string
# time, getTime() = 10; --> date
# timestamp, getTime() = 11; --> date
# PostgreSQL data types to Java classes information can be found at:
# http://www.postgresql.org/message-id/AANLkTinsk4rwT7v-751bwQkgTN1rkA=8uE-jk69nape-@mail.gmail.com
varchar=0
text=0
float4=7
float8=2
int4=5
oid=5
timestamp=8
date=8
bool=1
int2=5
int8=2
numeric=2
bpchar=9
现在可以了。您还应该检查您的 eclipse 的 java 版本是否与 driver.jar 的版本相同。否则你会得到这个异常:
java.lang.NoClassDefFoundError: java/time/temporal/TemporalField
我正在尝试将我的 postgresql
数据库连接到 Eclipse
中的 WEKA
。
当我 运行 主要我得到这个 exception
:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown data type: int4. Add entry in weka/experiment/DatabaseUtils.props.
If the type contains blanks, either escape them with a backslash or use underscores instead of blanks.
- 我下载了 WEKA 3-6-14
- 我解压了 weka.jar
- 我在 weka/experiment/DatabaseUtils.props.postgresql 文件中更改了 jdbc url 和 jdbc 驱动程序的行
- 我添加了我在数据库中使用的数据类型
- 我将 DatabaseUtils.props.postgresql 文件重命名为 DatabaseUtils.props
这是我的 DatabaseUtils 的一部分。props.postgresql 文件:
# Database settings for PostgreSQL 7.4
#
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# url: http://www.postgresql.org/
# jdbc: http://jdbc.postgresql.org/
# author: Fracpete (fracpete at waikato dot ac dot nz)
# version: $Revision: 11887 $
# JDBC driver (comma-separated list)
jdbcDriver=org.postgresql.Driver
# database URL
jdbcURL=jdbc:postgresql://localhost:5432/datamining
# specific data types
string, getString() = 0; --> nominal
boolean, getBoolean() = 1; --> nominal
double, getDouble() = 2; --> numeric
# byte, getByte() = 3; --> numeric
# short, getByte()= 4; --> numeric
int, getInteger() = 5; --> numeric
# long, getLong() = 6; --> numeric
# float, getFloat() = 7; --> numeric
# date, getDate() = 8; --> date
# text, getString() = 9; --> string
# time, getTime() = 10; --> date
# timestamp, getTime() = 11; --> date
# PostgreSQL data types to Java classes information can be found at:
# http://www.postgresql.org/message-id/AANLkTinsk4rwT7v-751bwQkgTN1rkA=8uE-jk69nape-@mail.gmail.com
text=0
boolean=1
double=2
int4=5
这是我的主要方法中的代码:
InstanceQuery query = new InstanceQuery();
query.setUsername("username");
query.setPassword("password");
query.setQuery("SELECT * FROM database ORDER BY \"id\"");
Instances data = query.retrieveInstances();
有人可以告诉我为什么我仍然收到异常吗?
尝试将 getter 添加到 DatabaseUtils.props.postgresql
我将 DatabaseUtils.props 代码更改为:
# Database settings for PostgreSQL 7.4
#
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# url: http://www.postgresql.org/
# jdbc: http://jdbc.postgresql.org/
# author: Fracpete (fracpete at waikato dot ac dot nz)
# version: $Revision: 11885 $
# JDBC driver (comma-separated list)
jdbcDriver=org.postgresql.Driver
# database URL
jdbcURL=jdbc:postgresql://localhost:5432/datamining
# specific data types
# string, getString() = 0; --> nominal
# boolean, getBoolean() = 1; --> nominal
# double, getDouble() = 2; --> numeric
# byte, getByte() = 3; --> numeric
# short, getByte()= 4; --> numeric
# int, getInteger() = 5; --> numeric
# long, getLong() = 6; --> numeric
# float, getFloat() = 7; --> numeric
# date, getDate() = 8; --> date
# text, getString() = 9; --> string
# time, getTime() = 10; --> date
# timestamp, getTime() = 11; --> date
# PostgreSQL data types to Java classes information can be found at:
# http://www.postgresql.org/message-id/AANLkTinsk4rwT7v-751bwQkgTN1rkA=8uE-jk69nape-@mail.gmail.com
varchar=0
text=0
float4=7
float8=2
int4=5
oid=5
timestamp=8
date=8
bool=1
int2=5
int8=2
numeric=2
bpchar=9
现在可以了。您还应该检查您的 eclipse 的 java 版本是否与 driver.jar 的版本相同。否则你会得到这个异常:
java.lang.NoClassDefFoundError: java/time/temporal/TemporalField