I apologize for the possibly stupid question, I am a beginner and only understand.

Trying to connect to the database. I use the code from the manual:

class JDBCVersion { public static void main (String args[]) throws SQLException { OracleDataSource ods = new OracleDataSource(); ods.setURL("jdbc:oracle:thin:jdbc/jdbc@localhost:1521/XE"); Connection conn = ods.getConnection(); // Create Oracle DatabaseMetaData object DatabaseMetaData meta = conn.getMetaData(); // gets driver info: System.out.println("JDBC driver version is " + meta.getDriverVersion()); } } 

Does not work:

Exception in thread "java.sql.SQLRecoverableException in thread: I / O Error: Undefined Error at oracle.jdbc.driver.T4CConnection.logon (T4CConnection.java:774) at oracle.jdbc.driver.PhysicalConnection.connect (PhysicalConnection.java : 688) at oracle.jdbc.driver.T4CDriverExtension.getConnection (T4CDriverExtension.java:39) at oracle.jdbc.driver.OracleDriver.connect (OracleDriver.java:691) at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection (OracleDataSource. java: 384) at oracle.jdbc.pool.OracleDataSource.getConnection (OracleDataSource.java:273) at oracle.jdbc.pool.OracleDataSource.getConnection (OracleDataSource.java:198) at oracle.jdbc.pool.OracleDataSource. .java: 176) at JDBC.JDBCVersion.main (JDBCVersion.java:12) Caused by: oracle.net.ns.NetException: Undefined Error at oracle.net.ns.NSProtocolNIO.negotiateConnection (NSProtocolNIO.java:271) at oracle .net.ns.NSProtocol.connect (NSProtocol.javaUE17) at oracle.jdbc.driver.T4CConnection.con nect (T4CConnection.java:1438) at oracle.jdbc.driver.T4CConnection.logon (T4CConnection.java spin18) ... 8 more

Means IDE connection to the database is normal. Please help me figure it out.

    2 answers 2

    The problem was solved by replacing regional settings before opening the connection:

     Locale.setDefault(Locale.ENGLISH); 

    Thanks to everyone who responded.

      Alternatively, you can try this way through DriverManager . He finds the driver he needs by the url view.

       public static Connection getConnection(String url, String user, String password) { try { Properties props = new Properties(); props.setProperty("user", user); props.setProperty("password", password); return DriverManager.getConnection(url, props); } catch (SQLException | ClassNotFoundException e) { logger.error(e); return null; } }