草庐IT

db-connect

全部标签

java - 如何将 Jdbc4Connection 转换为 PGConnection?

我想像这样使用postgresCopyManager:CopyManagercp=((PGConnection)dataSource.getConnection()).getCopyAPI();当我使用spring-boot时,数据源是org.apache.tomcat.jdbc.pool.DataSource,因此连接是Jdbc4Connection。问题:转换抛出以下错误:java.lang.ClassCastException:com.sun.proxy.$Proxy55cannotbecasttoorg.postgresql.PGConnection此外,当我尝试转换为Jdbc

java - Tomcat : HikariCP issue when deploying two applications with DB connection

我试图在同一个tomcat7实例上部署两个WAR文件(app1.war和app2.war)。我收到此错误:UnabletoregisterMBean[HikariDataSource(HikariPool-0)]withkey'dataSource';nestedexceptionisjavax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name=dataSource,type=HikariDataSource如果我在tomcat上只部署了一个应用程序,我就不会出现这个错误。有办法解决这个问题吗?

javax.mail.MessagingException : Could not connect to SMTP host?

以下是我发送邮件的代码:importjava.util.Properties;importjavax.mail.Authenticator;importjavax.mail.Message;importjavax.mail.Message.RecipientType;importjavax.mail.MessagingException;importjavax.mail.PasswordAuthentication;importjavax.mail.Session;importjavax.mail.Transport;importjavax.mail.internet.Internet

java - JUnit + Derby + Spring : drop in-memory db after every test

在我的单元测试中,我Autowiring了一些使用URL的数据源jdbc:derby:memory:mydb;create=true创建内存数据库。要删除内存中的Derby数据库,您必须连接:jdbc:derby:memory:mydb;drop=true我希望在每次测试后都发生这种情况,并从一个新的数据库开始。我如何使用Spring执行此操作? 最佳答案 HowtoshutdownDerbyin-memorydatabaseProperly给了我一个解决方案的提示:mydb.drop.url=jdbc:derby:memory:m

java.net.SocketException : Network is unreachable: connect 异常

我正在尝试使用此方法从Web服务器下载xml文本文件:staticvoiddownload(Stringurl,StringfileName)throwsIOException{FileWriterxmlWriter;xmlWriter=newFileWriter(fileName);System.out.println("URLtodownloadis:"+url);//hereExceptionisthrown/////////////////////////////////BufferedReaderinputTxtReader=newBufferedReader(newBuff

java - PreparedStatement 的 "close"与 Connection 的关系?

Javadoc说PreparedStatement的.close()说它..ReleasesthisStatementobject'sdatabaseandJDBCresourcesimmediatelyinsteadofwaitingforthistohappenwhenitisautomaticallyclosed.Itisgenerallygoodpracticetoreleaseresourcesassoonasyouarefinishedwiththemtoavoidtyingupdatabaseresources.CallingthemethodcloseonaStatem

java - 使用 Kafka Streams 开发时,Lib 上的 UnsatisfiedLinkError 会影响 DB dll

我正在我的开发Windows机器上编写KafkaStreams应用程序。如果我尝试使用KafkaStreams的leftJoin和branch功能,在执行jar应用程序时会出现以下错误:Exceptioninthread"StreamThread-1"java.lang.UnsatisfiedLinkError:C:\Users\user\AppData\Local\Temp\librocksdbjni325337723194862275.dll:Can'tfinddependentlibrariesatjava.lang.ClassLoader$NativeLibrary.load(

java - Kafka Connect 堆空间不足

启动KafkaConnect(connect-standalone)后,我的任务在启动后立即失败:java.lang.OutOfMemoryError:Javaheapspaceatjava.nio.HeapByteBuffer.(HeapByteBuffer.java:57)atjava.nio.ByteBuffer.allocate(ByteBuffer.java:335)atorg.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:93)atorg.apac

java - tomcat启动报错: DB name not found

在启动Tomcat时,出现以下错误:SEVERE:ExceptionlookingupUserDatabaseunderkeyUserDatabasejavax.naming.NameNotFoundException:NameUserDatabaseisnotboundinthisContextatorg.apache.naming.NamingContext.lookup(NamingContext.java:770)atorg.apache.naming.NamingContext.lookup(NamingContext.java:153)atorg.apache.catali

java - 如何使用 selenium 处理 firefox 中的 "Your connection is not secure"错误

我正在使用webdriverV3.0.1和firefoxV46。我遇到了“您的连接不安全”的错误。请帮我解决这个问题。你可以在下面找到我的代码System.setProperty("webdriver.gecko.driver","D:\\Software\\Webdriver\\geckonew\\geckodriver-v0.11.1-win64\\geckodriver.exe");FirefoxProfileprofile=newFirefoxProfile();profile.setPreference("network.proxy.type",0);profile.setA