Issue : I am getting below error
ORA-12519, TNS:no appropriate service handler found
Desc:
I want to configure threads and connection pool in tomcat to use them at optimum level. can i configure highly throughput up-to 500-600 threads, I have few more servlets which will use the database with similar threads.
I am calling a servlet to insert entry in db (code mentioned below) with 150 Threads with tasks to complete are 100000
static int joblimit = 100000;
static int TPS = 150;
public static void insertMethod()
{
RateLimiter rateLimiter = RateLimiter.create(TPS);
ExecutorService executorService = Executors.newCachedThreadPool();
start = System.currentTimeMillis();
for (int i = 0; i < joblimit; i++) {
rateLimiter.acquire(); // may wait
final int j = i;
executorService.execute(new Runnable() {
@Override
public void run() {
log.info(str);
try {
callInsertURL(j);
} catch (Exception e) {
log.error(e);
}
if (index == joblimit) {
long timeTaken = System.currentTimeMillis() - start;
String oneThreadProcessedInSecs = ""+(float)(1*(timeTaken/60)/joblimit);
log.info(joblimit + " jobs completed in "
+ timeTaken
+ " msec i.e ["+(float)(timeTaken/60)+"sec,"+"] with " + TPS + " tps, oneThreadProcessedInSecs="+oneThreadProcessedInSecs);
}
}
});
}
try {
executorService.shutdown();
executorService.awaitTermination(100, TimeUnit.SECONDS);
log.info("--------------All Tasks Processed Processed----------------------------");
} catch (Exception e) {
e.printStackTrace();
}
}
My Tomcat and Java configurations : Context.xml entry
<Resource name="jdbc/myoracle"
global="jdbc/myoracle"
auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@myip:1521:mydb"
username="myusername" password="mypassword" maxActive="250" maxIdle="30" maxWait="10000"
/>
server.xml entry
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
Springconfiguration: servlet-context.xml
<beans:bean id="dbDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<beans:property name="jndiName" value="java:comp/env/jdbc/myoracle"/>
</beans:bean>
ServeltController will be calling below method to insert into DB:
@Autowired
@Qualifier("commonDAO")
protected CommonDAO commonDAO;
String qry = "INSERT INTO TB_CUSTOMER(customer_msisdn,op_id,cuser,country_id) VALUES(?,?,?,?)";
String[] colNamesTobeReturned = {"CUSTOMER_ID"};
commonDAO.insertOrUpdateWithReturnPK(qry, colNamesTobeReturned, msisdn,opid,cuser,countryid);
Method which will access DB:
public Long insertOrUpdateWithReturnPK(final String qry,final String[] colNamesTobeReturned,final Object... params)
{
KeyHolder keyHolder = new GeneratedKeyHolder();
try {
getJdbcTemplate().update(
new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(qry, colNamesTobeReturned);
utilMapParamsToPStmt(ps,params);
return ps;
}
},
keyHolder);
if(keyHolder != null)
return keyHolder.getKey().longValue();
} catch (Exception e) {
handleDBExceptions(e);
}
return 0L;
}