连接到JDBC数据库时,`IO :: Socket :: INET:connect:Connection refused`

时间:2015-04-08 12:08:54

标签: database perl jdbc

我是Perl的新手,还有一个数据库连接脚本

sub db_connect {
    my ($database, $user, $password) = @_;

    my $driver = "JDBC";
    my $port = 14000;

    my $dsn = "dbi:JDBC:hostname=localhost:14000; url=jdbc:hsqldb:hsql://localhost:1111/$database;jdbc_character_set=ASCII";

    my $db_handler = DBI->connect($dsn, $user, $password ) or die $DBI::errstr;

    print "DB connected\n";
    return $db_handler;
}

以下是错误: -

process name:- com.vizdom.dbd.jdbc.ServerDBI connect('hostname=localhost:14000;url=jdbc:hsqldb:hsql://localhost:1111/EciToolDB;jdbc_character_set=ASCII','SA',...) failed: Failed to open socket to server: IO::Socket::INET: connect: Connection refused at ../lib/utils.pl line 66
Failed to open socket to server: IO::Socket::INET: connect: Connection refused at ../lib/utils.pl line 66.

1 个答案:

答案 0 :(得分:-1)

根据DBD::JDBC docs,您需要运行java服务器进程才能进行上述连接。看起来该进程在您尝试连接的端口上没有响应。

java -Djdbc.drivers=foo.bar.Driver -Ddbd.port=14000 com.vizdom.dbd.jdbc.Server