Page displaying '?', instead of 'é' - oracle

I am retriving data from oracle11g and displaying the data on IE8 and IE9 browser, but the couldn't display some special characters (eg. é)
In my webpage, I have explicitly declare 'UTF-8' encoding.
For my tomcat webserver, the server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
I read some other questions in stackflow, they mentioned to also ensure the database connection is using 'UTF-8' too.
<Resource name="jdbc/AppDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="20" maxIdle="10" maxWait="10000"
username="foo"
password="bar"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/ ID_development?useEncoding=true&characterEncoding=UTF-8"
/>
The solution given is for mysql.
How can i set the encoding if im using oracleDriver?
<Resource name="jdbc/AppDB"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#127.0.0.1:1521:ora11"
username="foo"
password="bar"
maxActive="20"
maxIdle="1000"
maxWait="-1" />

Please review this answer. Regardless of fact that it's focused on SQL Developer, it contains information about tuning JDBC driver and points out how to properly handle unicode character types in Oracle.
Update
Troubles with displaying characters on the client may be caused by wrong NLS_LANG settings on the database client (Tomcat in your case). For thin JDBC driver NLS_LANG value derived from java locale settings.
For possible variants you can look through the answers on this question and check Oracle documentation.
If a real source of the problem lies to character set of Oracle database connection, then there are only two possible end points to check: NLS_LANG and oracle.jdbc.defaultNChar . So you need to examine if both set properly to figure out what is happened.

Related

Can Tomcat support multiple JDBC connection pools?

I have a Spring Boot application which connects to different MySQL databases. I am planning to add connection pool support to this application. Does the Tomcat JDBC Connection Pool (default Spring boot pool) support more than one pool for each of my databases?
Not sure how this would be different under Spring Boot, but for standard web apps you can configure this at the webapp level, by adding in web.xml any number of the following:
<resource-ref>
<res-ref-name>jdbc/yourname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and in context.xml the corresponding number of the following:
<Resource name="jdbc/yourname" auth="Container" type="javax.sql.DataSource"
maxActive="30"
maxIdle="30"
maxWait="2000"
removeAbandoned="true"
...

Multiple application on multiple port not working - Tomcat

I want to host multiple applications on different ports on single instance of tomcat.
I have gone through the following link and made the following changes in my /etc/tomcat/server.xml file and added the following lines.
How to run different apps on single Tomcat instance behind different ports?
Server.xml
<Service name="app1">
<Connector port="8082" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
<Engine name="Catalina1" defaultHost="localhost">
<Host name="localhost" appBase="app1"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="app2">
<Connector port="8083" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
<Engine name="Catalina2" defaultHost="localhost">
<Host name="localhost" appBase="app2"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
In the appBase I have provided both the ways.
1. direct folder name.
2. path : webapps/temp.
The problem is when I hit the port 8082 and 8083, I dont get the default page It works for tomcat.
and I am not able to make call to my url.
Eg : ip:8082/temp/xyz/abc/param1=hello&param2=world
ip:8083/temp/xyz/abc/param1=hello&param2=world
When I see in network I am getting 404 error for my url.
But if Call the same url using port 8081 (Default configuration in server.xml) it works perfectly fine I get the response correctly.
What I am doing wrong here.
Also If possible please tell me the drawbacks and problems if I proceed in this way, to host multiple application on single tomcat instance.
Thanks
There are multiple issues with your current configuration. I recommend that you read though the other question you linked to carefully.
Specifically:
Service names must be unique
Engine names must be unique
appBase values must be unique
appBase values must not overlap
Personally, I wouldn't do it this way. I'd run everything under a single service/engine and use virtual hosting. You need to set up a DNS name for each service but with virtual hosting you avoid users having to include the port number in the URL they use to access the service.

hibernate.cfg.xml fails to reload with Tomcat/Spring 2

I'm using an older Spring 2 application with Tomcat and Hibernate. I was under the impression that I could change some settings in hibernate.cfg.xml, restart Tomcat, and the new settings (like a database connection) would take effect. Yet the old settings persist. What do I have to do to make these new changes go through? Here is an example of the xml:
<property name="connection.username">career</property>
<property name="connection.url">jdbc:oracle:thin:#192.168.76.46:1521:ISDD</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="myeclipse.connection.profile">my-careers</property>
<property name="connection.password">farcri</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
Let me know if more information is required.
i am not sure what your new settings are.Anyway they should be found.do you want to change database from one provider to oracle.Please put your tomcat output..You can do one thing that include log4j jar files so that you can see what tomcat is doing in detail manner.i think you are using myeclipse..do project clean such things..go to project and right click then do refresh..do close myeclipse and start again.
Hope this helps to you to figure out your problem.
As it turns out, hibernate.cfg.xml was not being read by the application. Instead, the database connection settings were placed in the ROOT.xml file in localhost. Not sure why this would be advantageous. Here is the relevant section of the ROOT.xml file:
<Resource name="jdbc/careers" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#192.168.76.55:1521:ISDD"
username="career" password="farcri" maxActive="20" maxIdle="10"
maxWait="-1"/>

Ibatis" Need to manage connections/datasources independently

The design of our application forces us to obtain our jdbc conncetions independently of the Ibatis session. We need a way to hand the connection (or alternately a datasource) to Ibatis and say "use this".
Have tries every search imaginable and can't find help.
Thanks in advance
If I understand you correctly, then you may configure your own JNDI that will be used by your application to get DataSource/Connection objects. Also you may pass this configured JNDI into iBatis:
<transactionManager type="EXTERNAL">
<dataSource type="JNDI">
<property name="DataSource"
value="java:comp/env/jdbc/someDataSource"/>
</dataSource>
</transactionManager>

spring not able to find JNDI data source

I am developing a spring web application . A JAR file which I use in my application , is looking for DataSource using JNDI. I configured the element in my tomcat's server.xml. The configuration is as below ,
<GlobalNamingResources>
<Resource name="jdbc/abcd"
auth="Container"
type="javax.sql.DataSource"
maxActive="70"
maxWait="10000"
username="xxxx" password="yyyy"
validationQuery="SELECT 1 from dual"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#xx.xxx.xx.xx:xxxx:zzzz"
testOnBorrow="false"
testOnReturn="false"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="120000"
minEvictableIdleTimeMillis="3600000"
/>
</GlobalNamingResources>
The Resource name configured above , "jdbc/abcd" is the same which the JAR is looking for,
But its not able to find this configured data source . Does anyone know what could be the reason ?
Am getting the below exception ,
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
You need to define a ResourceLink in the web application context that makes the global resource visible to the web application.
<ResourceLink
name="nameThatIsVisibleToTheWebApplication"
global="theGlobalName"
...
You need to do more than just configure Spring.
I'd recommend reading Tomcat JNDI documentation and this.

Resources