database 数据源德比 - 连接被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10420902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:32:17  来源:igfitidea点击:

data sources derby - connection refused

databasewebspheredatasourcederby

提问by Steffi

I am trying to connect a database with a java project. After reading some tutorials and the course support, I have understood that I need to make a new data source under the Admin Console.

我正在尝试将数据库与 java 项目连接。在阅读了一些教程和课程支持后,我明白我需要在 Admin Console 下创建一个新的数据源。

So, I've logged in into the admin console, then navigated to Resources -> JDBC -> Data Sources -> New; filled in the fields and when I am testing the connection, the error I get is this one:

所以,我已经登录到管理控制台,然后导航到 Resources -> JDBC -> Data Sources -> New;填写字段,当我测试连接时,我得到的错误是这个:

Messages The test connection operation failed for data source MyDB on server server1 at node RO2CVG6CNode01 with the following exception: java.sql.SQLNonTransientException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.DSRA0010E: SQL State = 08001, Error Code = 40,000. View JVM logs for further details.

消息 节点 RO2CVG6CNode01 上服务器 server1 上的数据源 MyDB 的测试连接操作失败,出现以下异常: java.sql.SQLNonTransientException: java.net.ConnectException :连接到端口 1527 上的服务器 localhost 时出错,消息连接被拒绝:connect.DSRA0010E: SQL 状态 = 08001,错误代码 = 40,000。查看 JVM 日志以获取更多详细信息。

I don't know where the problem is. Maybe with the Database name: jdbc:derby:D:\MyDB ? Can anyone help me please? I've also tried to use only MyDB, after this tutorial.
But still it doesn't work.

我不知道问题出在哪里。也许使用数据库名称: jdbc:derby:D:\MyDB ?有人可以帮我吗?在本教程之后,我还尝试仅使用 MyDB 。
但它仍然不起作用。

回答by Wayne Riesterer

Do you have the Derby Server running?

您是否正在运行 Derby Server?

It's quite possible that you are trying to connect to a database without the actual server running on Port 1527.

您很可能在没有实际服务器在端口 1527 上运行的情况下尝试连接到数据库。

You could try establishing a connection using the command line / linux shell - depending on what operating system you are using.

您可以尝试使用命令行 / linux shell 建立连接 - 取决于您使用的操作系统。

Try this if you like:

如果你喜欢,试试这个:

  1. Open a command prompt
  2. Navigate to your Derby installation directory
  3. Navigate to the "bin" directory(Note:Navigate Further to networkServer folder if it exists)
  4. Type "startNetworkServer" and press Enter
  1. 打开命令提示符
  2. 导航到您的 Derby 安装目录
  3. 导航到“bin”目录(注意:如果存在,请进一步导航到 networkServer 文件夹)
  4. 键入“startNetworkServer”并按 Enter

You should get a message that says something like this:

您应该收到一条消息,内容如下:

2012-08-29 10:57:16.559 GMT : Security manager installed using the Basic server security policy. 2012-08-29 10:57:16.809 GMT : Apache Derby Network Server - 10.6.2.1 - (999685) started and ready to accept connections on port 1527

2012-08-29 10:57:16.559 GMT:使用基本服务器安全策略安装的安全管理器。2012-08-29 10:57:16.809 GMT:Apache Derby 网络服务器 - 10.6.2.1 - (999685) 已启动并准备接受端口 1527 上的连接

If you don't, then maybe you could check your firewall (comments invited here :)

如果你不这样做,那么也许你可以检查你的防火墙(这里邀请评论:)

If you do, then you could test your connection using the following method:

如果这样做,那么您可以使用以下方法测试您的连接:

  1. Open another command prompt
  2. Navigate to your Derby installation directory
  3. Navigate to the "bin" directory
  4. Type "ij" and press Enter
  5. Type the following:

     connect 'jdbc:derby://localhost:1527/MyDB';
    

    ...and press Enter

  1. 打开另一个命令提示符
  2. 导航到您的 Derby 安装目录
  3. 导航到“bin”目录
  4. 输入“ij”并按 Enter
  5. 键入以下内容:

     connect 'jdbc:derby://localhost:1527/MyDB';
    

    ...然后按 Enter

If all goes well, you will get the "ij>" prompt back.

如果一切顺利,您将返回“ij>”提示。

From here you could enter some SQL queries to test the connection further.

从这里您可以输入一些 SQL 查询以进一步测试连接。

If not, then there might be some other problems.

如果没有,那么可能还有其他一些问题。

If you are creating the database for the first time in derby, then you would have to use this in place of Step 5 above:

如果您是第一次在 derby 中创建数据库,那么您必须使用它来代替上面的第 5 步:

     connect 'jdbc:derby://localhost:1527/MyDB;create=true';

...and press Enter

...然后按 Enter

Hopefully after doing these things, you will get a connection. In the last instance, you will at least get a new database called MyDB that is active on the Derby Server. If your original database (MyDB) is relatively small, then it might be quicker just to reconstruct it again for whatever purpose you need it for.

希望在做这些事情之后,你会得到一个连接。在最后一个实例中,您至少将获得一个名为 MyDB 的新数据库,该数据库在 Derby Server 上处于活动状态。如果您的原始数据库 (MyDB) 相对较小,那么为了您需要的任何目的再次重建它可能会更快。

Further to this, if you do establish a connection, then you could try other tools that you use for database development, since you have at least eliminated the possibility that the connection is the problem.

此外,如果您确实建立了连接,那么您可以尝试用于数据库开发的其他工具,因为您至少消除了连接是问题的可能性。

Just be sure to check the port number that is reported from Step 4. This is usually 1527. If not, then change the port number in Step 5 (or its replacement command for a new database) for whatever port is stated in the message from Derby.

请务必检查从第 4 步报告的端口号。这通常是 1527。如果不是,则在第 5 步(或它的新数据库替换命令)中更改端口号,用于消息中所述的任何端口德比。

Hope this helps and good luck :)

希望这会有所帮助并祝你好运:)

Wayne Riesterer

韦恩·里斯特

回答by Kurtcebe Eroglu

Did you define an authentication alias? Seems to be the same problem as the one in link below;

您是否定义了身份验证别名?似乎与下面链接中的问题相同;

http://www.webspheretools.com/sites/webspheretools.nsf/docs/Error%20when%20testing%20a%20JDBC%20connection%20to%20Derby

http://www.webspheretools.com/sites/webspheretools.nsf/docs/Error%20when%20testing%20a%20JDBC%20connection%20to%20Derby

Also if you check SystemOut.log you may see an error message telling which property is not set;

此外,如果您检查 SystemOut.log,您可能会看到一条错误消息,指出未设置哪个属性;

{"08001","Required Derby DataSource property {0} not set.","40000"},

{"08001","未设置所需的 Derby 数据源属性 {0}。","40000"},

回答by Salvatore Allegra

Check out the apache derby documentation here.....

在此处查看 apache derby 文档.....

Configure environment to use Derby Network Client JDBC driver

配置环境以使用 Derby Network Client JDBC 驱动程序

To use the Derby Network Client JDBCdriver, set your CLASSPATHto include the jar files listed below:

要使用该Derby Network Client JDBC驱动程序,请将您设置CLASSPATH为包含下面列出的 jar 文件:

  • derbyclient.jar: contains the JDBC driver
  • derbytools.jar: optional, provides the ij tool
  • derbyclient.jar:包含 JDBC 驱动程序
  • derbytools.jar:可选,提供 ij 工具

You can set your CLASSPATHexplicitly with the command shown below: Windows:

您可以CLASSPATH使用如下所示的命令明确设置:Windows:

C:\> set CLASSPATH=%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbytools.jar;.

UNIX:

UNIX:

$ export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:.

Then try creating a database like this after entering the ij command at a prompt.....ij> connect

然后在提示符下输入 ij 命令后尝试创建这样的数据库..... ij> connect

jdbc:derby://localhost:1527/Chapter01DB;create=true;

回答by Amit Kaneria

  1. Download derby to following location:

    /home/ <user_directory> /apache-derby/
    
  2. Setup classpath/paths as below:

    export DERBY_HOME=/home/<user_directory>/magister-database
    
    export DERBY_INSTALL=/home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin
    
    export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:$CLASSPATH
    
  3. Start network server:

    /home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin/bin/startNetworkServer
    
  4. Run derby command line as below:

    java org.apache.derby.tools.ij
    
    connect 'jdbc:derby://localhost:1527//home/<user_directory>/<database-directory>/<database-name>';
    
    show tables;
    
    disconnect;
    
    exit;
    
  1. 将 derby 下载到以下位置:

    /home/ <user_directory> /apache-derby/
    
  2. 设置类路径/路径如下:

    export DERBY_HOME=/home/<user_directory>/magister-database
    
    export DERBY_INSTALL=/home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin
    
    export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:$CLASSPATH
    
  3. 启动网络服务器:

    /home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin/bin/startNetworkServer
    
  4. 运行 derby 命令行如下:

    java org.apache.derby.tools.ij
    
    connect 'jdbc:derby://localhost:1527//home/<user_directory>/<database-directory>/<database-name>';
    
    show tables;
    
    disconnect;
    
    exit;