I am trying to create a Tomcat JNDI resource for MSSQL database.
This is how my resource string looks in tomcat context.xml file
<Resource
name="jdbc/FI/SD"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://LDIA;databaseName=SD"
validationQuery="Select 1"
maxActive="1" maxIdle="1" maxWait="10000"
user="rels"
password="hidden"
/>
This is the code snippet that i am using in Servlet to check datasource:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/FI/SD");
Connection conn = ds.getConnection();
but i am getting this error while creating connection at line 4,
how can i solve this:
org.apache.tomcat.dbcp.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (Login failed for user ''. The user is not associated with a trusted SQL Server connection.)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at com.MyServlet.doGet(MyServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
Maybe user should be username instead?
Related
In tomcat9 there is a setting in context.xml:
<Resource name="jdbc/db2xx" auth="Container"
type="javax.sql.DataSource" driverClassName="com.ibm.db2.jcc.DB2Driver"
maxTotal="100" maxIdle="30"
maxWaitMillis="-1" username="xx" password="xx"
url="jdbc:db2://xxxx:xxx/dbname;" />
and in Java is :
try {
Class.forName("com.ibm.db2.jcc.DB2SimpleDataSource");
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
com.ibm.db2.jcc.DB2SimpleDataSource ds = (com.ibm.db2.jcc.DB2SimpleDataSource) envContext.lookup("jdbc/db2xx");
ds.setClientProgramName("MyApplication");
conn = ds.getConnection();
}
But I get error :
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to com.ibm.db2.jcc.DB2SimpleDataSource
Do I have to change
org.apache.tomcat.dbcp.dbcp2.BasicDataSource
where ?
The main point is
ds.setClientProgramName("MyApplication");
because I would like to see
MyApplication in APPLICATION_NAME
when I run
SELECT APPLICATION_NAME FROM TABLE(MON_GET_CONNECTION(CAST(NULL AS BIGINT),-2))
or is there any other way ?
If I am using javax.sql.DataSource program works, but I can not use setClientProgramName.
In maven pom :
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.7.0</version>
</dependency>
Client info properties support by the IBM Data Server Driver for JDBC and SQLJ.
ApplicationName
ClientAccountingInformation
ClientHostname
ClientUser
These properties mentioned at the link above can't be set with URL.
They can be set with the JDBC 4 method (use db2jcc4.jar, not db2jcc.jar which is JDBC 3 implementation) setClientInfo only like below:
conn = ds.getConnection();
conn.setClientInfo("ApplicationName", "MyApplication");
My mission is to connect Tomcat 7 to remote IBM MQ. I try create JNDI Resource in server.xml file but it doesn't work. I used example from.
Addinatinaly i added in this example username and password. But there is error when i call JNDI resource from java code.
<Resource
name="jms/MyQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="<mymqserver>"
PORT="1414"
CHAN="<mychannel>"
TRAN="1"
QMGR="<myqueuemanager>"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="<myqueue>"/>
I've downloaded all required *.jars from [IBM sphere]/lib/java to Tomcat lib folder. Help me please, mb i'm doing somethink wrong. Maybe i need some IBM Client, but i don't know what is it.
Edit:
The error stacktrace
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
VERSION OF IBM MQ LIBS IS:
Implementation-Version: 7.0.1.8 - k701-108-120201
My current Resource in server.xml is:
<Resource
name="jms/MyQCF"
auth="Container"
type="org.springframework.jms.connection.CachingConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="192.168.204.73"
PORT="1415"
username="***"
password="***"
CHAN="JAVA.CHANNEL"
TRAN="1"
QMGR="U.SEND"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="U.RECEIVE"/>
My java code:
System.out.println("servlet page*****************");
Context ctx = null;
try {
ctx = (Context) new InitialContext().lookup("java:comp/env");
System.out.println("ctx: " + ctx);
} catch (NamingException e) {
e.printStackTrace();
}
QueueConnectionFactory qcf = null;
try {
qcf = (QueueConnectionFactory) ctx.lookup("jms/MyQCF");
System.out.println("qcf: " + qcf);
} catch (NamingException e) {
e.printStackTrace();
}
My stacktrace:
servlet page*****************
ctx: org.apache.naming.NamingContext#463b1a3e
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at kz.lalafa.MyServlet.doPost(MyServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
My Tomcat lib folder contains:
annotations-api.jar
fscontext.jar
catalina-ant.jar
geronimo-j2ee-management_1.1_spec-1.0.1.jar
catalina-ha.jar
geronimo-jms_1.1_spec-1.1.1.jar
catalina.jar
jasper-el.jar
catalina-tribes.jar
jasper.jar
CL3Export.jar
jms.jar
CL3Nonexport.jar
jndi.jar
com.ibm.mq.commonservices.jar
jsp-api.jar
com.ibm.mq.defaultconfig.jar
jta.jar
com.ibm.mqetclient.jar
ldap.jar
com.ibm.mq.headers.jar
providerutil.jar
com.ibm.mq.jar
rmm.jar
com.ibm.mq.jmqi.jar
servlet-api.jar
com.ibm.mqjms.jar
tomcat-api.jar
com.ibm.mq.jms.Nojndi.jar
tomcat-coyote.jar
com.ibm.mq.pcf.jar
tomcat-dbcp.jar
com.ibm.mq.postcard.jar
tomcat-i18n-es.jar
com.ibm.mq.soap.jar
tomcat-i18n-fr.jar
com.ibm.mq.tools.ras.jar
tomcat-i18n-ja.jar
connector.jar
tomcat-jdbc.jar
dhbcore.jar
tomcat-util.jar
ecj-4.2.2.jar
wmq.jmsra.rar
el-api.jar
My web.xml:
<?xml version='1.0' encoding='utf-8'?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-env-ref>
<resource-env-ref-name>jms/MyQCF</resource-env-ref-name>
<resource-env-ref-type>javax.jms.QueueConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/MyQ</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</web-app>
I just decided to use Spring Boot for this - https://github.com/lzp4ever/IBM_WebSphere_MQ_Spring_Boot_JMS.
But i got new problem. My new problem at this link: multiple jms connection factory
I am using JNDI datasource to connect to Postgres database. This is the code to of my ServletContextListener
public void contextInitialized(ServletContextEvent event) {
try {
// Obtain our environment naming context
Context envCtx = (Context) new InitialContext().lookup("java:comp/env");
// initialize JNDI lookup parameters
DataSource datasource = (DataSource) envCtx.lookup("jdbc/testdb");
ManagerDao.getConn(datasource);
ParticipantDao.getConn(datasource);
EventDao.getConn(datasource);
FacilitiesDao.getConn(datasource);
}
catch (NamingException e) {
e.printStackTrace();
}
}
web.xml of App_path\WebContent\WEB-INF
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/testdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
context.xml
<Resource name="jdbc/testdb"
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password="rules#123"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5433/eventory"
maxActive="20" maxIdle="10"
/>
But I am getting errors while the getConnection() methods are getting called.
java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2167)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2037)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1543)
at com.eventory.dao.FacilitiesDao.getConn(FacilitiesDao.java:26)
at com.eventory.initDB.DBConnListener.contextInitialized(DBConnListener.java:48)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(Unknown Source)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2151)
... 13 more
I have tried the following approaches:
Put the postgresql-42.1.4.jar in the tomcat lib folder.
Put the postgresql-42.1.4.jar in the App_Path\WebContent\WEB-INF\lib
Put the context.xml in the WebContent\META-INF folder
Put the context.xml in the tomcat\conf folder
Nothing seems to work. Is there any other approach that I missed? Please help.
We have several jobs running in springbatch. We restarted the server this morning and afterwards we started having issues with two of the jobs. The BATCH_STEP_EXECUTION table shows the following exit message for each failed execution:
org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doRollback(DataSourceTransactionManager.java:286)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:846)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:823)
at org.springframework.transaction.support.TransactionTemplate.rollbackOnException(TransactionTemplate.java:162)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:135)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:267)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:253)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:141)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:151)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:130)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:301)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:134)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.ja
This appears to be in relation to the mysql connection the application is making, however I'm not sure what could have caused this as the application was functioning fine before the reboot. Has anyone stumbled across this before?
EDIT
(caused by message that appears in the logs)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
Datasource
javax.sql.DataSource
Connection Pool
Configured in context.xml file with the following format:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="webapps/appname" mapperContextRootRedirectEnabled="true" mapperDirectoryRedirectEnabled="true" path="/appname" reloadable="false" >
<Resource name="jdbc/springbatchmeta"
auth="Container"
type="javax.sql.DataSource"
username="${jobmeta.username}"
password="${jobmeta.password}"
driverClassName="${mysql.driverClass}"
url="${jobmeta.url}"
initialSize="2"
maxTotal="20"
maxIdle="10"
minIdle="2"/>
<Resource name="jdbc/firstjob"
auth="Container"
type="javax.sql.DataSource"
username="${firstjob.username}"
password="${firstjob.password}"
driverClassName="${mysql.driverClass}"
url="${firstjob.url}"
initialSize="2"
maxTotal="20"
maxIdle="10"
minIdle="2"/>
<Resource name="jdbc/secondjob"
auth="Container"
type="javax.sql.DataSource"
username="${secondjob.username}"
password="${secondjob.password}"
driverClassName="${secondjob.driverClass}"
url="${secondjob.url}"
initialSize="2"
maxTotal="20"
maxIdle="10"
minIdle="2"/>
</Context>
This issue was caused by the wait-timeout option in mysql being set to 60 seconds, as most of the jobs we are running take over a minute to complete.
Brushing up on my Java skills guys. I used to declare my connection details in Java inside classes. I decided to try to use context and #Resource method this time and is having some errors
INFO: Server startup in 1701 ms
java.sql.SQLException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:thin#//10.30.30.30:1521/mydatabase?useSSL=false'
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2065)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:1939)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
at com.pldt.itms.FirstServlet.doGet(FirstServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2056)
... 27 more
Below is my context.xml inside WebContent/META-INF
<?xml version="1.0"?>
<Context>
<Resource url="jdbc:oracle:thin#//10.30.30.30:1521/mydatabase?useSSL=false" driverClassName="oracle.jdbc.driver.OracleDriver" password="password" username="username" maxWait="10000" maxIdle="5" maxActive="20" type="javax.sql.DataSource" auth="Container" name="jdbc/web_my_context"/>
</Context>
Here is my Java Class
package com.company.project;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
/**
* Servlet implementation class FirstServlet
*/
#WebServlet("/FirstServlet")
public class FirstServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
#Resource(name="jdbc/web_my_context")
DataSource dataSource;
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//1 printwriter
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
//2 connect to db
Connection myConn = null;
Statement myStmt = null;
ResultSet myRs = null;
try{
myConn = dataSource.getConnection();
//3 create sql
String sql = "select * from table_authorities";
myStmt = myConn.createStatement();
//4 execute sql
myRs = myStmt.executeQuery(sql);
//5 process resultset of sql statment
while (myRs.next()){
String email = myRs.getString("username");
out.println(email);
}
} catch (Exception exc) {
exc.printStackTrace();
}
response.getWriter().append("Served at: ").append(request.getContextPath());
}
}
EDIT:
I corrected my xml
<?xml version="1.0"?>
<Context>
<Resource url="jdbc:oracle:thin:#//10.30.30.30:1521/mydatabase?useSSL=false" driverClassName="oracle.jdbc.driver.OracleDriver" password="password" username="username" maxWait="10000" maxIdle="5" maxActive="20" type="javax.sql.DataSource" auth="Container" name="jdbc/web_my_context"/>
</Context>
But now it is still throwing an error:
Caused by: oracle.net.ns.NetException: Listener refused the connection
with the following error: ORA-12514, TNS:listener does not currently
know of service requested in connect descriptor at
oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:272)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263) at
oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360) at
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486) ... 35
more
As others have pointed out you have a syntax error in your xml the proper syntax is
jdbc:oracle:thin:#//HOSTNAME:PORT/SERVICENAME
I think your just having typos from switching between Oracle and MySQL, I recommend not doing that when posting a question so we can help you accurately and to do that we need the most current syntax.
updated answer
I think the one causing your error is actually this line over here
'jdbc:oracle:thin#//10.30.30.30:1521/mydatabase?useSSL=false'
AFAIK useSSL=false only works for MySQL and not for Oracle database.
Try removing useSSL=false in your xml. Your code should now look like this
'jdbc:oracle:thin#//10.30.30.30:1521/mydatabase'
I believe that by default Oracle does not use SSL you no longer need to explicityly say it to not use SSL. Just in case you want to use SSL for Oracle you will have to use the tcps protocol, you can do this by using the long detailed TNS style like this.
jdbc:oracle:thin:#(description=(address=(host=HOSTNAME)(protocol=tcps)(port=PORT))(connect_data=(service_name=SERVICENAME)(server=SHARED)))
If your interested in configuring your Oracle connection to use SSL you can check their documentation over at this LINK.