草庐IT

connection-manager

全部标签

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 - 调用 createEntityManagerFactory 时为 "You cannot set autocommit during a managed transaction"

我正在尝试通过在我的应用程序中分离模式来实现Multi-Tenancy。为此,我有一个Tenant实体,其中包含一个StringschemaName,并且我有一个SingletonStartupEJB在启动时创建EntityManagerFactory的映射;一个工厂分配给每个Tenant。这是我的EJB:@Startup@SingletonpublicclassTenantManagementServiceImplimplementsTenantManagementService{privateMapentityManagerFactoryMap;@PersistenceContex

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 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 - java.sql.SQLException :[Microsoft][ODBC Driver Manager] Invalid descriptor index 异常

我使用下面的代码try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connectioncon=DriverManager.getConnection("jdbc:odbc:access");Stringsql="Select*fromtable";Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery(sql);ResultSetMetaDatamd=rs.getMetaData();intcolumns=md.getColumnCount();for(inti

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

java - 捕捉 Ctrl+C 信号抛出异常 "Job manager has been shut down"

我正在尝试添加对信号的支持(尤其是对于Ctrl+C)。我的工具是用Java编写的,我想在Ctrl+C被捕获时执行清理。我的主文件是应用程序,有以下和平代码:if(ArgDefinitions.getInstance().hasOption(ArgNames.EXECUTE)){performShutdownHooks();preformRun();}应用程序解析用户的选项并运行正确的方法。因此,当用户使用execute选项并单击Ctrl+C时,我希望程序停止并清理该区域。我添加了performShutdownHooks方法来处理信号,它看起来如下:privatevoidperformS