oracle.jdbc.driver.PhysicalConnection 看JDBC的参数

本文详细介绍了通过Java连接Oracle数据库时所需配置的各种属性及其默认值,包括用户认证、网络设置、安全配置等关键参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

private void readConnectionProperties(java.lang.String s, java.util.Properties properties) throws java.sql.SQLException { java.lang.String s1 = null; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.RetainV9LongBindBehavior"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.RetainV9LongBindBehavior", null); if(s1 == null) s1 = "false"; retainV9BindBehavior = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("user"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.user"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.user", null); if(s1 == null) s1 = null; userName = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("database"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.database"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.database", null); if(s1 == null) s1 = null; database = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("autoCommit"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.autoCommit"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.autoCommit", null); if(s1 == null) s1 = "true"; autocommit = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("protocol"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.protocol"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.protocol", null); if(s1 == null) s1 = null; protocol = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.StreamChunkSize"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.StreamChunkSize", null); if(s1 == null) s1 = "16384"; try { streamChunkSize = java.lang.Integer.parseInt(s1); } catch(java.lang.NumberFormatException numberformatexception) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'streamChunkSize'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("SetFloatAndDoubleUseBinary"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.SetFloatAndDoubleUseBinary"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.SetFloatAndDoubleUseBinary", null); if(s1 == null) s1 = "false"; setFloatAndDoubleUseBinary = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.ocinativelibrary"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.ocinativelibrary", null); if(s1 == null) s1 = null; ocidll = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.terminal"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.terminal"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.terminal", null); if(s1 == null) s1 = "unknown"; thinVsessionTerminal = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.machine"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.machine"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.machine", null); if(s1 == null) s1 = null; thinVsessionMachine = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.osuser"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.osuser"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.osuser", null); if(s1 == null) s1 = null; thinVsessionOsuser = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.program"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.program"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.program", null); if(s1 == null) s1 = "JDBC Thin Client"; thinVsessionProgram = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.process"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.process"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.process", null); if(s1 == null) s1 = "1234"; thinVsessionProcess = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.iname"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.iname"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.iname", null); if(s1 == null) s1 = "jdbc_ttc_impl"; thinVsessionIname = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("v$session.ename"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.v$session.ename"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.v$session.ename", null); if(s1 == null) s1 = null; thinVsessionEname = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.profile"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.profile", null); if(s1 == null) s1 = null; thinNetProfile = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.authentication_services"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.authentication_services", null); if(s1 == null) s1 = null; thinNetAuthenticationServices = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.kerberos5_mutual_authentication"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.kerberos5_mutual_authentication", null); if(s1 == null) s1 = null; thinNetAuthenticationKrb5Mutual = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.kerberos5_cc_name"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.kerberos5_cc_name", null); if(s1 == null) s1 = null; thinNetAuthenticationKrb5CcName = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.encryption_client"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.encryption_client", null); if(s1 == null) s1 = null; thinNetEncryptionLevel = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.encryption_types_client"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.encryption_types_client", null); if(s1 == null) s1 = null; thinNetEncryptionTypes = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.crypto_checksum_client"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.crypto_checksum_client", null); if(s1 == null) s1 = null; thinNetChecksumLevel = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.crypto_checksum_types_client"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.crypto_checksum_types_client", null); if(s1 == null) s1 = null; thinNetChecksumTypes = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.crypto_seed"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.crypto_seed", null); if(s1 == null) s1 = null; thinNetCryptoSeed = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.TcpNoDelay"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.TcpNoDelay", null); if(s1 == null) s1 = "false"; thinTcpNoDelay = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.ReadTimeout"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.ReadTimeout", null); if(s1 == null) s1 = null; thinReadTimeout = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.CONNECT_TIMEOUT"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.CONNECT_TIMEOUT", null); if(s1 == null) s1 = null; thinNetConnectTimeout = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.disableOob"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.disableOob", null); if(s1 == null) s1 = "false"; thinNetDisableOutOfBandBreak = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.use1900AsYearForTime"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.use1900AsYearForTime", null); if(s1 == null) s1 = "false"; use1900AsYearForTime = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.timestampTzInGmt"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.timestampTzInGmt", null); if(s1 == null) s1 = "true"; timestamptzInGmt = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.ssl_server_dn_match"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.ssl_server_dn_match", null); if(s1 == null) s1 = null; thinSslServerDnMatch = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.ssl_version"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.ssl_version", null); if(s1 == null) s1 = null; thinSslVersion = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.ssl_cipher_suites"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.ssl_cipher_suites", null); if(s1 == null) s1 = null; thinSslCipherSuites = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.keyStore"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.keyStore", null); if(s1 == null) s1 = null; thinJavaxNetSslKeystore = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.keyStoreType"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.keyStoreType", null); if(s1 == null) s1 = null; thinJavaxNetSslKeystoretype = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.keyStorePassword"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.keyStorePassword", null); if(s1 == null) s1 = null; thinJavaxNetSslKeystorepassword = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.trustStore"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.trustStore", null); if(s1 == null) s1 = null; thinJavaxNetSslTruststore = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.trustStoreType"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.trustStoreType", null); if(s1 == null) s1 = null; thinJavaxNetSslTruststoretype = s1; s1 = null; if(properties != null) s1 = properties.getProperty("javax.net.ssl.trustStorePassword"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("javax.net.ssl.trustStorePassword", null); if(s1 == null) s1 = null; thinJavaxNetSslTruststorepassword = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("ssl.keyManagerFactory.algorithm"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.ssl.keyManagerFactory.algorithm"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.ssl.keyManagerFactory.algorithm", null); if(s1 == null) s1 = null; thinSslKeymanagerfactoryAlgorithm = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("ssl.trustManagerFactory.algorithm"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.ssl.trustManagerFactory.algorithm"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.ssl.trustManagerFactory.algorithm", null); if(s1 == null) s1 = null; thinSslTrustmanagerfactoryAlgorithm = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.oldSyntax"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.oldSyntax", null); if(s1 == null) s1 = null; thinNetOldsyntax = s1; s1 = null; if(properties != null) s1 = properties.getProperty("java.naming.factory.initial"); if(s1 == null) s1 = null; thinNamingContextInitial = s1; s1 = null; if(properties != null) s1 = properties.getProperty("java.naming.provider.url"); if(s1 == null) s1 = null; thinNamingProviderUrl = s1; s1 = null; if(properties != null) s1 = properties.getProperty("java.naming.security.authentication"); if(s1 == null) s1 = null; thinNamingSecurityAuthentication = s1; s1 = null; if(properties != null) s1 = properties.getProperty("java.naming.security.principal"); if(s1 == null) s1 = null; thinNamingSecurityPrincipal = s1; s1 = null; if(properties != null) s1 = properties.getProperty("java.naming.security.credentials"); if(s1 == null) s1 = null; thinNamingSecurityCredentials = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.wallet_location"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.wallet_location", null); if(s1 == null) s1 = null; walletLocation = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.net.wallet_password"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.net.wallet_password", null); if(s1 == null) s1 = null; walletPassword = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.proxyClientName"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.proxyClientName", null); if(s1 == null) s1 = null; proxyClientName = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("JDBCDriverCharSetId"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.JDBCDriverCharSetId"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.JDBCDriverCharSetId", null); if(s1 == null) s1 = null; ociDriverCharset = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.editionName"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.editionName", null); if(s1 == null) s1 = null; editionName = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.thinLogonCapability"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.thinLogonCapability", null); if(s1 == null) s1 = "o5"; logonCap = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("internal_logon"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.internal_logon"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.internal_logon", null); if(s1 == null) s1 = null; internalLogon = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.createDescriptorUseCurrentSchemaForSchemaName"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.createDescriptorUseCurrentSchemaForSchemaName", null); if(s1 == null) s1 = "false"; createDescriptorUseCurrentSchemaForSchemaName = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("OCISvcCtxHandle"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.OCISvcCtxHandle"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.OCISvcCtxHandle", null); if(s1 == null) s1 = "0"; try { ociSvcCtxHandle = java.lang.Long.parseLong(s1); } catch(java.lang.NumberFormatException numberformatexception1) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'ociSvcCtxHandle'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("OCIEnvHandle"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.OCIEnvHandle"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.OCIEnvHandle", null); if(s1 == null) s1 = "0"; try { ociEnvHandle = java.lang.Long.parseLong(s1); } catch(java.lang.NumberFormatException numberformatexception2) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'ociEnvHandle'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("OCIErrHandle"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.OCIErrHandle"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.OCIErrHandle", null); if(s1 == null) s1 = "0"; try { ociErrHandle = java.lang.Long.parseLong(s1); } catch(java.lang.NumberFormatException numberformatexception3) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'ociErrHandle'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("prelim_auth"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.prelim_auth"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.prelim_auth", null); if(s1 == null) s1 = "false"; prelimAuth = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.ociNlsLangBackwardCompatible"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.ociNlsLangBackwardCompatible", null); if(s1 == null) s1 = "false"; nlsLangBackdoor = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("OCINewPassword"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.OCINewPassword"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.OCINewPassword", null); if(s1 == null) s1 = null; setNewPassword = s1; s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.spawnNewThreadToCancel"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.spawnNewThreadToCancel", null); if(s1 == null) s1 = "false"; spawnNewThreadToCancel = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("defaultExecuteBatch"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.defaultExecuteBatch"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.defaultExecuteBatch", null); if(s1 == null) s1 = "1"; try { defaultExecuteBatch = java.lang.Integer.parseInt(s1); } catch(java.lang.NumberFormatException numberformatexception4) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'defaultExecuteBatch'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("defaultRowPrefetch"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.defaultRowPrefetch"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.defaultRowPrefetch", null); if(s1 == null) s1 = "10"; try { defaultRowPrefetch = java.lang.Integer.parseInt(s1); } catch(java.lang.NumberFormatException numberformatexception5) { oracle.jdbc.driver.DatabaseError.throwSqlException(getConnectionDuringExceptionHandling(), 190, "Property is 'defaultRowPrefetch'"); } s1 = null; if(properties != null) { s1 = properties.getProperty("remarksReporting"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.remarksReporting"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.remarksReporting", null); if(s1 == null) s1 = "false"; reportRemarks = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("includeSynonyms"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.includeSynonyms"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.includeSynonyms", null); if(s1 == null) s1 = "false"; includeSynonyms = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("restrictGetTables"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.restrictGetTables"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.restrictGetTables", null); if(s1 == null) s1 = "false"; restrictGettables = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("AccumulateBatchResult"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.AccumulateBatchResult"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.AccumulateBatchResult", null); if(s1 == null) s1 = "true"; accumulateBatchResult = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("useFetchSizeWithLongColumn"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.useFetchSizeWithLongColumn"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.useFetchSizeWithLongColumn", null); if(s1 == null) s1 = "false"; useFetchSizeWithLongColumn = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("processEscapes"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.processEscapes"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.processEscapes", null); if(s1 == null) s1 = "true"; processEscapes = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("fixedString"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.fixedString"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.fixedString", null); if(s1 == null) s1 = "false"; fixedString = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("defaultNChar"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.defaultNChar"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.defaultNChar", null); if(s1 == null) s1 = "false"; defaultnchar = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.internal.permitBindDateDefineTimestampMismatch"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.internal.permitBindDateDefineTimestampMismatch", null); if(s1 == null) s1 = "false"; permitTimestampDateMismatch = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) { s1 = properties.getProperty("RessourceManagerId"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.RessourceManagerId"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.RessourceManagerId", null); if(s1 == null) s1 = "0000"; resourceManagerId = s1; s1 = null; if(properties != null) { s1 = properties.getProperty("disableDefineColumnType"); if(s1 == null) s1 = properties.getProperty("oracle.jdbc.disableDefineColumnType"); } if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.disableDefineColumnType", null); if(s1 == null) s1 = "false"; disableDefinecolumntype = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.convertNcharLiterals"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.convertNcharLiterals", null); if(s1 == null) s1 = "false"; convertNcharLiterals = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.J2EE13Compliant"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.J2EE13Compliant", null); if(s1 == null) s1 = "false"; j2ee13Compliant = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.mapDateToTimestamp"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.mapDateToTimestamp", null); if(s1 == null) s1 = "true"; mapDateToTimestamp = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.useThreadLocalBufferCache"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.useThreadLocalBufferCache", null); if(s1 == null) s1 = "false"; useThreadLocalBufferCache = s1 != null && s1.equalsIgnoreCase("true"); s1 = null; if(properties != null) s1 = properties.getProperty("oracle.jdbc.commitOption"); if(s1 == null) s1 = oracle.jdbc.driver.PhysicalConnection.getSystemProperty("oracle.jdbc.commitOption", null); if(s1 != null) { commitOption = 0; java.lang.String as[] = s1.split(","); if(as != null && as.length > 0) { java.lang.String as1[] = as; int j = as1.length; for(int k = 0; k < j; k++) { java.lang.String s3 = as1[k]; if(s3.trim() != "") commitOption |= oracle.jdbc.OracleConnection.CommitOption.valueOf(s3.trim()).getCode(); } } }

<think>好的,用户遇到了Oracle JDBC驱动程序被弃用的问题,需要替换旧的oracle.jdbc.driver.OracleDriver为新的oracle.jdbc.OracleDriver。首先,我需要确认新驱动类的正确性。根据引用[1],Oracle确实推荐使用新的接口,所以替换是必要的。 接下来,用户可能需要修改代码中的驱动类名。原来的Class.forName("oracle.jdbc.driver.OracleDriver")要改成新的。同时,要注意JDBC URL的格式是否有变化,通常还是jdbc:oracle:thin:@host:port:SID或者使用服务名。 然后,用户可能使用的依赖版本是否支持新驱动。需要检查pom.xml或Gradle文件中的ojdbc版本,至少要是10g以后的版本,比如ojdbc8或更高。如果版本过旧,需要升级。 另外,用户可能在代码中使用了某些被弃用的类或方法,比如Datum相关类。根据引用[3],BUG-6525017涉及序列化Datum子类时的异常,建议避免使用这些过时的类,改用java.sql包中的标准接口。 还可能遇到ORA-26038之类的错误,如引用[2]提到的字符长度字段转换问题,这可能需要检查数据类型的匹配,确保数据库表和Java实体类型一致。 最后,用户可能需要了解如何正确配置连接池,比如在Spring Boot中使用application.properties指定驱动类名和URL。同时,确保相关文档参考Oracle的最新指南,如引用[1]提到的JDBC开发者指南。 总结步骤:替换驱动类、更新依赖、检查URL、替换弃用类、处理兼容性问题、测试连接。需要一步步引导用户操作,并提醒常见错误和解决方法。</think>### 如何替换已弃用的Oracle JDBC驱动类名 #### 1. **替换驱动类名** 旧的驱动类`oracle.jdbc.driver.OracleDriver`已被弃用,需替换为新的标准类名: ```java // 旧代码(已弃用) Class.forName("oracle.jdbc.driver.OracleDriver"); // 新代码(推荐) Class.forName("oracle.jdbc.OracleDriver"); ``` 新类名属于`oracle.jdbc`包,而非`oracle.jdbc.driver`[^1]。 --- #### 2. **检查JDBC URL格式** 确保连接URL使用标准的Oracle JDBC格式: - 使用**SID**: `jdbc:oracle:thin:@host:port:SID` 例如:`jdbc:oracle:thin:@localhost:1521:ORCL` - 使用**服务名**: `jdbc:oracle:thin:@//host:port/service_name` 例如:`jdbc:oracle:thin:@//db-server:1521/mydb.service.com` --- #### 3. **更新JDBC依赖版本** 在Maven/Gradle中确认使用**ojdbc8及以上版本**(以Maven为例): ```xml <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>21.9.0.0</version> </dependency> ``` 旧版本(如ojdbc6/7)可能不完全兼容新驱动类。 --- #### 4. **替换弃用的API** 避免使用`oracle.jdbc.driver`包中的类,例如: - 旧:`oracle.jdbc.driver.OracleResultSet` 新:使用`java.sql.ResultSet`接口替代 - 旧:`oracle.sql.*`(如`Datum`) 新:改用标准JDBC类型(如`java.sql.Date`, `Blob`)[^3] --- #### 5. **处理兼容性问题** 若出现类似`ORA-26038`错误(如字符到数字转换失败),需检查: - 数据库表字段类型与Java代码中`PreparedStatement`设置的类型是否匹配 - 使用`getObject()`和`setObject()`时是否明确指定类型[^2] --- #### 6. **连接池配置示例** 以Spring Boot的`application.properties`为例: ```properties spring.datasource.driver-class-name=oracle.jdbc.OracleDriver spring.datasource.url=jdbc:oracle:thin:@//db-host:1521/service_name spring.datasource.username=your_username spring.datasource.password=your_password ``` --- ### 常见问题解决 | 问题场景 | 解决方案 | |---------|----------| | `ClassNotFoundException: oracle.jdbc.OracleDriver` | 检查依赖版本是否包含新驱动类 | | `ORA-28040`(认证协议错误) | 升级Oracle服务端或使用`ojdbc10+`驱动 | | `ORA-01722`(无效数字) | 使用`PreparedStatement.setInt()`等明确类型方法 |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值