简体   繁体   中英

Issues with connect to Apache Derby database on Raspberry Pi

I am working on a Java project where I make apache Derby Database connections in Netbeans with maven. I want to export project to Raspberry PI, but when i am trying to execute jar file i got an error:

java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused.

On local computer database connects normally when I start server manually, if not i got same error.

I understand that i didnt started database server on Raspberry PI, but I can't find where and how to do it..

I assume that the database server runs on another machine and you can reach it from raspberry pi over network.

It tries to connect to the database server on localhost (Raspberry Pi). Since it is not running on localhost and running on another machine, you need to change the server IP address in order to connect to the database server that runs on other machine.

Check database connection string which has hostname/ip and port. As "dbhost" and "dbport" variables below:

String url = "jdbc:postgresql://" + dbhost + 
                ":" + dbport + "/" + dbname;

You can check following JDBC tutorial for more details:

Java Database Connectivity

For information about running the Derby Network Server, see the Derby Admin Guide at https://db.apache.org/derby/docs/10.12/adminguide/index.html

Specifically, see https://db.apache.org/derby/docs/10.12/adminguide/tadmincbdjhhfd.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM