package org.jinjiabao.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TestConnection {
public static void main(String[] args) throws ClassNotFoundException, SQLException{
String user = "lisi";
String password = "lisi";
//String url = "jdbc:oracle:thin:@localhost:1521:ORCL";
String url = "jdbc:oracle:thin:@192.168.1.100:1521:ORCL";
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("Connection: " + conn);
}
}
出现的异常:
Exception in thread "main" java.sql.SQLRecoverableException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:458)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.jinjiabao.jdbc.TestConnection.main(TestConnection.java:21)
分享到:
相关推荐
NULL 博文链接:https://lbay.iteye.com/blog/784874
The Network Adapter could not establish the connection
Oracle10G控制台解决办法-Io 异常:Unknown host specified解决方法
当遇到“连接不到数据库”的问题时,通常会显示如"Io异常: The Network Adapter could not establish the connection"这样的错误信息。这个异常表明应用程序无法与数据库建立网络连接,可能由多种原因造成。以下是...
6. 连接 Oracle 时抛出如下异常:java.sql.SQLException: Io exception: The Network Adapter could not establish connection 解决方法: * 检查 Oracle 实例是否正常运行。 * 检查连接数据库的用户名和密码是否...
在Android应用开发中,用户界面(UI)的状态管理是一项至关重要的任务。这涉及到如何优雅地展示数据加载、数据为空、网络请求失败等不同场景。在本文中,我们将深入探讨如何实现"View各种状态的切换",包括数据加载...
Could not resolve dependencies for project org.apache.flink:flink-avro-confluent-registry:jar:1.15.3: Could not find artifact io.confluent:kafka-schema-registry-client:jar:6.2.2 in maven 安装本地...
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.WinForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies....
Failure to transfer org.... Original error: Could not transfer artifact org.codehaus.plexus:plexus-io:jar: 1.0.1 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000
在windows环境下的eclipse或者idea中编写spark应用时,有时为了验证程序功能需要以本地模式运行...java.io.Exception: Could not locate executable null\bin\winutils.exe in the Hadoop binarie 本文件可以解决此异常
报错:java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.-附件资源
同时,理解线程调度器(如`Schedulers.io()`、`Schedulers.mainThread()`等)的工作原理也非常重要,它们帮助开发者在合适的线程上执行操作,保证应用的响应性和性能。 总之,RxJava 3.x作为Java和Android开发中...
docker load -i prometheus-adapter-v0.9.1.tar.gz ; docker images |grep k8s.gcr.io/prometheus-adapter/prometheus-adapter
在编程过程中,尤其是在使用C#进行文件系统操作时,可能会遇到这样一个问题:当你尝试删除一个目录,系统返回“System.IO.IOException: 目录不是空的”错误。这意味着该目录下仍有文件或子目录存在,因此无法直接...
当你尝试`Test Driver`时,可能会遇到“Error while performing database login with the oracle.jdbc.driver.OracleDriver driver: Io exception: The Network Adapter could not establish the connection”的错误...
Java.io.CharConversionException: isHexDigit 是 Java 中一种常见的异常,通常发生在传输数据时编码不正确或 URL 传值时出现问题。本文将对该异常进行详细分析,介绍导致该异常的原因和解决方法。 一、问题描述 ...
Android Studio上运行Flutter,报错could not find io.flutter:flutter_embedding_debug的错误,需要替换以上zip文件即可,Android Studio 4.2.0, Flutter 2.2.3, Dart 2.13.4
6. **IO异常处理**:提供了一些更易用的异常类,使得处理IO异常时的代码更简洁。 7. **缓冲区操作**:提供了`BufferedInputStream`和`BufferedOutputStream`的增强版本,提高了读写性能。 8. **路径处理**:提供了...