2015-04-08 76 views
0

我新的Perl和有數據庫連接`IO ::插座:: INET:連接:連接到數據庫的JDBC連接時refused`

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

你可以發佈你的完整代碼,並告訴我們關於第66行嗎? – serenesat

+0

只是要清楚,它不是* db_handler *,它是* db_handle *。有一個巨大的差異 – Borodin

+0

my $ db_handler = DBI-> connect($ dsn,$ user,$ password)或者死於$ DBI :: errstr;這是行號。 66 –

回答

-1

根據DBD::JDBC docs,您需要運行java服務器進程才能進行上述連接。它看起來像你正試圖連接的端口沒有響應。

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