Bhavani Kumar

Greenhorn
+ Follow
since Feb 22, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bhavani Kumar

1. Using an SQL editor, check the content of the database. Make sure the string is properly inserted. (I wonder why you are using unicode strings like this...)
2. What does the String contains after fetching data from the DB ? Either debug it, or output the String in a file and open the file with an editor which supports unicode.
3. How did you set the web page encoding ?



1. Japanese string is properly inserted in the DB. I had read in Oracle Technical Network that non-ascii strings could be inserted in this way. When I query this string using "select unistr('\0041\0063\0063\0065\0073\0073\0020\004d\0061\006e\0061\0067\0065\006d\0065\006e1\006e\0061\0067\0065\006d\0065\006e\0074\0020\0054\006f\006f\006c\0020\304b\3089\306e') from dual;" then it is showing me the correct japanese message.
2. String contains all ???. I saw printing it on the browser as well as in the log.
3. Web page encoding is set in the Websphere server that we use and is set to 'ISO8859-1'.

I have tried converting the mydatabasestring to correct japanese string in below ways but still only question marks (???) appear.

out.println("1."+new String(mydatabasestring.getBytes("UTF-8"),"ISO-2022-JP"));
out.println("2."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"UTF-8"));
out.println("3."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"ISO-2022-JP"));
out.println("4."+new String(mydatabasestring.getBytes("Cp1252"),"Cp1252"));
out.println("5."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"Cp1252"));
out.println("6."+new String(mydatabasestring.getBytes("Cp1252"),"ISO-2022-JP"));
out.println("7."+new String(mydatabasestring.getBytes("UTF-8"),"Cp1252"));
out.println("8."+new String(mydatabasestring.getBytes("Cp1252"),"UTF-8"));

Is there anything that I am missing here ???
I am fetching a Japanese string from Oracle Database and displaying it on the browser. But the characters are shown on the browser like ???. Inserted the Japanese string into DB using the unistr() function.INSERT INTO MESSAGES (MESSAGE_ID,MESSAGE) VALUES (1,unistr('\0041\0063\0063\0065\0073\0073\0020\004d\0061\006e\0061\0067\0065\006d\0065\006e'));

I got this in my jvm logs 'ISO8859-1' when I printed System.getProperty("file.encoding").

select * from v$nls_parameters where parameter in ('NLS_CHARACTERSET') yields 'UTF8' in my DB.

Any pointers on how the Japanese characters could be displayed correctly ?
Hi All,
I have a J2EE web project which runs on WAS and has Oracle 8i as the database. Now we are considering to upgrade the DB from 8i to 10g.

I would like to know what are the steps that need to be taken care of from the front end (java code) so that the project runs similar to how it used to run with 8i.
Hi All,
I have a J2EE web project which runs on WAS and has Oracle 8i as the database. Now we are considering to upgrade the DB from 8i to 10g.

I would like to know what are the steps that need to be taken care of from the front end (java code) so that the project runs similar to how it used to run with 8i.
12 years ago
Hi all,
My scenario is : I have 2 combos in a Composite. Depending on the value selected in the first Combo, the second Combo is populated. Now the values in the second combo are of variable length, so i need to resize the combo depending on the length of the text. Is it possible, since we place the combos on the composite in the beginning itself ?

Code:

msgFmtCmb = new Combo(paramComp, SWT.READ_ONLY);
gridData = new GridData();
gridData.horizontalSpan = 2;
msgFmtCmb.setLayoutData(gridData);
msgFmtCmb.addModifyListener(this);

msgTypeCmb = new Combo(paramComp, SWT.READ_ONLY);
final GridData grdDataMsgType = new GridData();
grdDataMsgType.horizontalSpan = 2;
msgTypeCmb.setLayoutData(grdDataMsgType);
msgTypeCmb.addModifyListener(this);

In the modifyText method, i am removing all values from the second combo and adding new values.
13 years ago
Thanks for the help Rajesh ! But i was looking for how to add Checkboxes in SWT and not in Swing....a code snippet will be of great help.
14 years ago
hi,
can anyone tell me how to add checkboxes in a list ?
14 years ago
Let me be more clear on what i want :

int i=10;

now if i say System.out.println(i);
it shows '10' on the console.

but i want 'int' to be printed on the console ('int' is i's datatype)
14 years ago
Hi,
how do i print the datatype a variable ?

Thanking you in advance.

Bhavani.
14 years ago
Can I create connection pooling with data sources using sybase driver(jconn2.jar)? I am working on this for quite an amount of time but in vain. The exception raised is :

Exception in thread "main" java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection (PoolingDataSource.java:161)

My program looks like this :

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.dbcp.DriverManagerConnectionFactory;

public class ManualPoolingDataSourceExample {
public static void main(String[] args) {
String url = "jdbc:sybase:Tds:172.16.12.84:2048/lnk_common_dd";
System.out.println("Loading underlying JDBC driver.");

try {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
System.out.println("Done.");
System.out.println("Setting up data source.");
DataSource dataSource = setupDataSource(url);
System.out.println("Done.");
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;

try {
System.out.println("Creating connection.");
conn = dataSource.getConnection("sa","");
System.out.println("Done.");
System.out.println("Creating statement.");
stmt = conn.createStatement();
System.out.println("Executing statement.");
rset = stmt.executeQuery("select * from testdata");
System.out.println("Results:");
int numcols = rset.getMetaData().getColumnCount();
while(rset.next()) {
for(int i=1;i<=numcols;i++) {
System.out.print("\t" + rset.getString(i));
}
System.out.println("");
}
} catch(SQLException e) {
e.printStackTrace();
} finally {
try { rset.close(); } catch(Exception e) { }
try { stmt.close(); } catch(Exception e) { }
try { conn.close(); } catch(Exception e) { }
}
}

public static DataSource setupDataSource(String connectURI) {
ObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);
PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
return dataSource;
}
}

And i've placed all the necessary jars in the classpath ie :

commons-dbcp1.1.jar
commons-collections.jar
commons-pool1.2.jar
jconn2.jar
j2ee.jar
14 years ago
hi craig,

the problem still persists even after making the changes that you have suggested.

regarding closing of Resource tag: Since we are mapping the 'name' attribute of ResourceParams with the 'name' attribute of Resource , so there would not be much of a problem. But still i've tried by changing it,still the problem persists.
14 years ago
yeah craig, i am accessing test.jsp by localhost:8080/DBTest2/test.jsp and the context /DBTest2 is loading properly. can you suggest alternative methods of implementing connection pooling apart from the method i am following.

Thanks
14 years ago
hello everyone,
i am trying to implement connection pooling with sybase as the database and tomcat 5 as the container. But this is the exception thats coming :

javax.naming.NameNotFoundException: Name jdbc/TestDB2 is not bound in
this Context

My server.xml looks lilke this :
<Context path="/DBTest2" docBase="DBTest2" debug="5" reloadable="true" crossContext="true" >

<Logger classname="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest2_log." suffix=".txt" timestamp="true" />

<Resource name="jdbc/TestDB2" auth="Container" type="javax.sql.DataSource" />

<ResourceParams name="jdbc/TestDB2">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>username</name>
<value>sa</value>
</parameter>

<parameter>
<name>password</name>
<value></value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:sybase:Tds:172.16.12.84:2048/lnk_common_dd</value>
</parameter>

</ResourceParams>

</Context>

This is my web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app 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"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


this is my test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<sql:query var="rs" dataSource="jdbc/TestDB2">
select id, foo, bar from testdata
</sql:query>

<html>
<head>
<title>DB Test</title>
</head>
<body>

<h2>Results</h2>

<c:forEach var="row" items="${rs.rows}">
Foo ${row.foo}<br/>
Bar ${row.bar}<br/>
</c:forEach>

</body>
</html>

Any help would be much appreciated as i am stuck with this since the last 2 days

thanking you all in advance

Bhavani
hello everyone,
i am trying to implement connection pooling with sybase as the database and tomcat 5 as the container. But this is the exception thats coming :

javax.naming.NameNotFoundException: Name jdbc/TestDB2 is not bound in
this Context

My server.xml looks lilke this :
<Context path="/DBTest2" docBase="DBTest2" debug="5" reloadable="true" crossContext="true" >

<Logger classname="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest2_log." suffix=".txt" timestamp="true" />

<Resource name="jdbc/TestDB2" auth="Container" type="javax.sql.DataSource" />

<ResourceParams name="jdbc/TestDB2">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>username</name>
<value>sa</value>
</parameter>

<parameter>
<name>password</name>
<value></value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:sybase:Tds:172.16.12.84:2048/lnk_common_dd</value>
</parameter>

</ResourceParams>

</Context>

This is my web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app 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"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


this is my test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<sql:query var="rs" dataSource="jdbc/TestDB2">
select id, foo, bar from testdata
</sql:query>

<html>
<head>
<title>DB Test</title>
</head>
<body>

<h2>Results</h2>

<c:forEach var="row" items="${rs.rows}">
Foo ${row.foo}<br/>
Bar ${row.bar}<br/>
</c:forEach>

</body>
</html>

Any help would be much appreciated as i am stuck with this since the last 2 days

thanking you all in advance

Bhavani
14 years ago
hello everyone,
i've planned to write sun certified java course in 4 months time....could you guide me in this regard by advising me on how to prepare and schedule time....thanking you in advance
14 years ago