Rishi Tyagi

Ranch Hand
+ Follow
since Feb 14, 2002
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 Rishi Tyagi

Hi
I would like to start study on JPA /Object Relational Mapping, I use Netbeans 8.0 as IDE, Is there some good tutorial available online to start with?

Regs,
Rishi Tyagi
Hi,

I have a java servlet url which is shared with soem thirdparty, my servlet url is

http://<mydomain>/calback


Thirdparty is passing information to my servlet in below format
http://<mydomain>/calback#data=<data i need to read from this request>

Can someone advice how can i read this data being received after # in the invoked url

tried getAttributes(), getPathInfo(), getParameterNames(), getRequestURI() and getRequestURL() but none of them is returning me data passed to me url after #

Kindly advice how can i sortout this issue and read required data?

5 years ago
Dear All,

I am creating a small application which reads some wmv media contents from hard disk and updates database as well.

Now while updating record for these media file i need to access following properties for a wmv or wma content
1- duration
2- width and hight

All these properties are being shown in Advanced properties of the file property dialog when we right click on the file and go to properties option. But i am not able to find a way to access these properties using java applications.

In there anybody who has ever faced the same problem and can guide me to do that.

Regs,
Rishi Tyagi
12 years ago
Dear All,
I am facing a strange problem with jdbc-odbc bridge database driver. Problem is as follows:
I wrote a small script to read data from one database table at my local MS SQL server and after that inserting a record in another database.

Now problem is that everything works fine, even executeUpdate() method gives me 1 after running insert query but when i check into database there is nothing in the destination database. Could not understand why is it happening, in fact it happened first time with me.

All java classes being used are as follows:
To get Database connection : DatabaseConnection.java

package com.xmedia.sms.db;


import java.util.Properties;


public class DatabaseConnection {
public static java.util.Properties props;
private String dbName;
private String dbUser;
private String dbPassword;
private String driverName;
private String dbUrl;
static{
try{
java.io.InputStream is = Class.forName("com.xmedia.sms.db.DatabaseConnection").getResourceAsStream("/properties/db.properties");
props = new java.util.Properties();
props.load(is);
}catch(Exception e){
props=null;
System.out.println("Either Database property '/properties/db.properties' file does not exists or corrupted");
}
}
public DatabaseConnection() {
}

public Properties getProps() {
return props;
}

public void setDbName(String dbName) {
this.dbName = dbName;
try{
setDbUrl((String)props.getProperty((dbName+".url")));
setDbUser((String)props.getProperty((dbName+".user")));
setDbPassword((String)props.getProperty((dbName+".password")));
}catch(Exception e){}
}

public void setDbUser(String dbUser) {
this.dbUser = dbUser;
}

public void setDbPassword(String dbPassword) {
this.dbPassword = dbPassword;
}

public void setDriverName(String driverName) {
this.driverName = driverName;
}

public void setDbUrl(String dbUrl) {
this.dbUrl = dbUrl;
}

public String getDbName() {
return dbName;
}

public String getDbUser() {
return dbUser;
}

public String getDbPassword() {
return dbPassword;
}

public String getDriverName() {
return driverName;
}

public String getDbUrl() {
return dbUrl;
}

public java.sql.Connection connect(){
java.sql.Connection conn=null;
try{
setDriverName((String)props.getProperty("drivers"));
setDbUrl((String)props.getProperty((dbName+".url")));
setDbUser((String)props.getProperty((dbName+".user")));
setDbPassword((String)props.getProperty((dbName+".password")));
Class.forName(getDriverName().trim());
conn=java.sql.DriverManager.getConnection(dbUrl.trim(),dbUser.trim(),dbPassword.trim());

}catch(Exception e){
conn=null;
System.out.println("Error while connecting with database :"+e);
}
return conn;
}
}

-------------------------

To pick records from the source database i am using following code:
public List getRecordsFromSource()
{
List list=new ArrayList();
Connection conn=null;

dbConn.setDbName(sourceDBName);
conn=dbConn.connect();
if(conn!=null)
{
try{
Statement st=conn.createStatement();
if(debug==true)
System.out.println("Executing SELECT QUERY :"+sourceSQLQuery);
ResultSet rs=st.executeQuery(sourceSQLQuery);
while(rs.next())
{

String[] strData=new String[22];
strData[0]=rs.getString("ID");
strData[1]=rs.getString("MessageRaw");
strData[2]=rs.getString("MessageDataType");
strData[3]=rs.getString("Message");
strData[4]=rs.getString("SourceMSISDN");
strData[5]=rs.getString("SourceType");
strData[6]=rs.getString("SourceDate");
strData[7]=rs.getString("SourceCountry");
strData[8]=rs.getString("SourceOperator");
strData[9]=rs.getString("DestinationNumber");
strData[10]=rs.getString("ImageId");
strData[11]=rs.getString("Nickname");
strData[12]=rs.getString("Status");
strData[13]=rs.getString("Archive");
strData[14]=rs.getString("ModeratorId");
strData[15]=rs.getString("TrackModeratorId");
strData[16]=rs.getString("ModeratorTimeStamp");
strData[17]=rs.getString("ModeratedDate");
strData[18]=rs.getString("Rank");
strData[19]=rs.getString("ServiceId");
strData[20]=rs.getString("ServiceSectionId");
strData[21]=rs.getString("ConnectionId");
if(debug==true)
{
System.out.print("ID :"+strData[0]+",");
//System.out.println("MsgRaw :"+strData[1]+",");
}
list.add(strData);
strData=null;
}

rs.close();
rs=null;
st.close();
st=null;
}catch(Exception e){
list=new ArrayList();
}
}

try{
if(conn!=null)
conn.close();
}catch(Exception e){
}
conn=null;


return list;

}
-----------------
To insert data into destination database i am using following code:

public int insertRecordsToDestination(String[] str)
{
int rep=0;
Connection conn=null;

dbConn.setDbName(destDBName);
conn=dbConn.connect();
if(conn!=null)
{
try{
//Statement st=conn.createStatement();
for(int i=0;i<str.length;i++)
{if(str[i]!=null && str[i].length()>0)
str[i]=str[i].trim();
else
{
if(i==0 || i==2 || i==3 || i==5 || i==6 || i==7 || i==8 || i==10 || i==15 || i==16)
str[i]="";
else
str[i]="0";
}
}
String sqlQuery="Insert Into SMS2Air_Messages(MessageRaw, MessageDataType, Message, SourceMSISDN,SourceType, SourceDate,SourceCountry,SourceOperator,DestinationNumber,ImageId,Nickname,Status,Archive,ModeratorId,TrackModeratorId,ModeratorTimeStamp,ModeratedDate,Rank,ServiceId,ServiceSectionId,ConnectionId) Values ('" + str[1] + "'," + str[2] + ",N'" + str[3] + "','" + str[4] + "'," + str[5] + ",'" + str[6] + "','" + str[7] + "','" + str[8] + "','" + str[9] + "'," + str[10] + ",N'" + str[11] + "'," + str[12] + "," + str[13] + "," + str[14] + "," + str[15] + ",'" + str[16] + "','" + str[17] + "'," + str[18] + "," + str[19] + "," + str[20] + "," + str[21] + ")";
if(debug==true)
System.out.println("Executing INSERT QUERY :"+sqlQuery);
com.xmedia.java.RUtil.saveToFile(""+str[0].trim()+".txt",sqlQuery);
Statement st=conn.createStatement();
rep=st.executeUpdate(sqlQuery);
conn.commit();
if(debug==true)
System.out.println("RESULT INSERT QUERY :"+rep);
sqlQuery=null;

st.close();
st=null;
}catch(Exception e){
rep=-1;
if(debug==true)
System.out.println("Error :"+e);
}
}

try{
if(conn!=null)
conn.close();
}catch(Exception e){
}
conn=null;


return rep;

}

-----------------------

Following is the method invoking both of above methods:

public void startServer()
{

int ctr=0;
setDebug(true);
while(isProcessFlag())
{
if(ctr==0)
System.out.println("Started at......"+new java.sql.Timestamp(System.currentTimeMillis()));

List sourceList=getRecordsFromSource();
int n1=sourceList.size();
System.out.println("sourceList Length :"+n1);
System.out.println("Inserting Data..");
ListIterator listItr=sourceList.listIterator();
String idList="";
int n=0;
while(listItr.hasNext())
{
String[] strData=(String[])listItr.next();
System.out.println("strData[0]:"+strData[0]);
int rep=insertRecordsToDestination(strData);
if(rep>0)
{
idList= idList.trim() +","+strData[0];
n += rep;
}
System.out.print(".."+strData[0]);
strData=null;
}
System.out.println("idList :"+idList);
System.out.println(""+n+" Out of "+n1+" Records Inserted successfully");
System.out.println("Last Time Invoked at..."+new java.sql.Timestamp(System.currentTimeMillis())+", Counter:"+ctr);
ctr++;
Wait(30);
}

}



----------------------

Kindly note that Database Collation is same at both source and destination database and in jdbc -odbc bridge i am using default language.

Records also contains some unicode data specially in Message and NickName database fields.

Is there anybody who has ever faced the same type problem and can help my why it is happening.
Best Regs,
Rishi Tyagi

[ May 17, 2006: Message edited by: Rishi Tyagi ]
[ May 17, 2006: Message edited by: Rishi Tyagi ]
Thanks James,
Will try in this way. Lets hope if it helps us.
Regs,
Rishi Tyagi
12 years ago
Thanks James,

But as you mentioned that we need to make dll JNI compatible, what we need to do for that?

Actually the api i want to use is a third party api and i dont have source of it and hence it is next to impossible to make any change in that dll.
Is there any way so that we can invoke dll without touching it.

Regs,
Rishi
12 years ago
Dear All,

I am working on a project which needs to use an dll api originaly written to be used with visual basic or other microsoft platform languages like VC++ etc.

Is there any way to use a dll api in java , I heard that using JNI we can do this, but could not get the proper information to use JNI for invoking objects and their methods into java application which are embedded inside dll api.

Is there anybody who has ever done this before and can share his experience with me here.


Regs,
Rishi Tyagi
12 years ago
Dear All,
I am facing some problem while using jdbc dbc bridge driver in the java beans and servlets hosted on Jrun3.1 to connect with microsoft SQL server.
Problem is it creates a error dump and server gets stopped atleast 5-6 times a day. Kindly let me know the exact reason of the error as well as remeady for the same. Following is the sample of dump it creates in error logs


An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x7C82F350
Function=RtlEnterCriticalSection+0x19
Library=C:\WINDOWS\system32\ntdll.dll

Current Java thread:
at sun.jdbc.odbc.JdbcOdbc.allocConnect(Native Method)
at sun.jdbc.odbc.JdbcOdbc.SQLAllocConnect(JdbcOdbc.java:114)
at sun.jdbc.odbc.JdbcOdbcDriver.allocConnection(JdbcOdbcDriver.java:929)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:126)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
- locked <02EB3C58> (a sun.jdbc.odbc.JdbcOdbcDriver)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
- locked <06A6CEA0> (a java.lang.Class)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
- locked <06A6CEA0> (a java.lang.Class)
at com.rishi.db.DBConnection.getConnection(DBConnection.java:50)
at com.multimedia.smscollect.servlet.XCellSMSCollectionServletVIP.service(XCellSMSCollectionServletVIP.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1417)
at allaire.jrun.session.JRunSessionService.service(JRunSessionService.java:1088)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:1271)
at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:39)
at allaire.jrun.servlet.Invoker.service(Invoker.java:84)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1417)
at allaire.jrun.session.JRunSessionService.service(JRunSessionService.java:1088)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:1271)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:89)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1557)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1547)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:364)
at allaire.jrun.http.WebEndpoint.run(WebEndpoint.java:115)
at allaire.jrun.ThreadPool.run(ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(WorkerThread.java:75)

Dynamic libraries:
0x00400000 - 0x00406000 C:\PROGRA~1\Java\J2RE14~1.1\bin\javaw.exe
0x7C800000 - 0x7C8C0000 C:\WINDOWS\system32\ntdll.dll
0x77E40000 - 0x77F42000 C:\WINDOWS\system32\kernel32.dll
0x77F50000 - 0x77FEC000 C:\WINDOWS\system32\ADVAPI32.dll
0x77C50000 - 0x77CEF000 C:\WINDOWS\system32\RPCRT4.dll
0x77380000 - 0x77412000 C:\WINDOWS\system32\USER32.dll
0x77C00000 - 0x77C48000 C:\WINDOWS\system32\GDI32.dll
0x77BA0000 - 0x77BFA000 C:\WINDOWS\system32\MSVCRT.dll
0x62D80000 - 0x62D89000 C:\WINDOWS\system32\LPK.DLL
0x75490000 - 0x754F1000 C:\WINDOWS\system32\USP10.dll
0x6D330000 - 0x6D45C000 C:\PROGRA~1\Java\J2RE14~1.1\bin\client\jvm.dll
0x76AA0000 - 0x76ACD000 C:\WINDOWS\system32\WINMM.dll
0x6D1D0000 - 0x6D1D7000 C:\PROGRA~1\Java\J2RE14~1.1\bin\hpi.dll
0x6D300000 - 0x6D30D000 C:\PROGRA~1\Java\J2RE14~1.1\bin\verify.dll
0x6D210000 - 0x6D229000 C:\PROGRA~1\Java\J2RE14~1.1\bin\java.dll
0x6D320000 - 0x6D32D000 C:\PROGRA~1\Java\J2RE14~1.1\bin\zip.dll
0x76F50000 - 0x76F63000 C:\WINDOWS\system32\Secur32.dll
0x6D2D0000 - 0x6D2DE000 C:\Program Files\Java\j2re1.4.1\bin\net.dll
0x71BB0000 - 0x71BB9000 C:\WINDOWS\system32\WSOCK32.dll
0x71C00000 - 0x71C17000 C:\WINDOWS\system32\WS2_32.dll
0x71BF0000 - 0x71BF8000 C:\WINDOWS\system32\WS2HELP.dll
0x71B20000 - 0x71B61000 C:\WINDOWS\system32\mswsock.dll
0x5F270000 - 0x5F2C9000 C:\WINDOWS\system32\hnetcfg.dll
0x71AE0000 - 0x71AE8000 C:\WINDOWS\System32\wshtcpip.dll
0x76ED0000 - 0x76EF9000 C:\WINDOWS\system32\DNSAPI.dll
0x76F70000 - 0x76F77000 C:\WINDOWS\System32\winrnr.dll
0x76F10000 - 0x76F3E000 C:\WINDOWS\system32\WLDAP32.dll
0x76F80000 - 0x76F85000 C:\WINDOWS\system32\rasadhlp.dll
0x6D250000 - 0x6D25B000 C:\Program Files\Java\j2re1.4.1\bin\JdbcOdbc.dll
0x4BF70000 - 0x4BFAD000 C:\WINDOWS\system32\ODBC32.dll
0x77530000 - 0x775C7000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.1830_x-ww_1B6F474A\COMCTL32.dll
0x762B0000 - 0x762FA000 C:\WINDOWS\system32\comdlg32.dll
0x7C8D0000 - 0x7D0D3000 C:\WINDOWS\system32\SHELL32.dll
0x77DA0000 - 0x77DF2000 C:\WINDOWS\system32\SHLWAPI.dll
0x77420000 - 0x77523000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.1830_x-ww_7AE38CCF\comctl32.dll
0x0B790000 - 0x0B7A7000 C:\WINDOWS\system32\odbcint.dll
0x77670000 - 0x777A4000 C:\WINDOWS\system32\ole32.dll
0x77B90000 - 0x77B98000 C:\WINDOWS\system32\VERSION.dll
0x4D7A0000 - 0x4D7BA000 C:\WINDOWS\system32\odbccp32.dll
0x76C90000 - 0x76CB7000 C:\WINDOWS\system32\msv1_0.dll
0x76CF0000 - 0x76D0A000 C:\WINDOWS\system32\iphlpapi.dll
0x76B70000 - 0x76B7B000 C:\WINDOWS\system32\PSAPI.DLL
0x76C10000 - 0x76C39000 C:\WINDOWS\system32\imagehlp.dll
0x6D580000 - 0x6D628000 C:\WINDOWS\system32\dbghelp.dll

Local Time = Fri Nov 04 18:38:41 2005
Elapsed Time = 13734
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.1-b21 mixed mode)
#


Regs,
Rishi
13 years ago
What happened,
Out of so many java guru's no body responded for the problem.

Regs,
Rishi
13 years ago
Hi,

I working on a application where input is 7bit encoded hex Strings(GSM 7-bit encoding).
For example "C8329BFD06" is the 7-bit encoded string of "Hello" and "41F1980C" is the 7-bit encoded hex string of "Abcd"

I need to decode this data into the original Ascii characters. For this i wrote a small script but it gives me junk characters.

Is there anybody who can help me to sortout the problem.

My script code is as follows:

public String decode7BitMsg(int msgLength,String msg)
{
String respMsg="";

try{
String binaryStr=hexToBinary(msg);
int n=binaryStr.length()/7;
if(binaryStr.length()%7>0)
{while(binaryStr.length()%7>0)
binaryStr +="0";
n++;
}
System.out.println("Binary String :"+binaryStr);

for(int i=0;i<n;i++)
{
String str="";
if(binaryStr.length()>7)
{
str=binaryStr.substring(0,7);
binaryStr=binaryStr.substring(7);
}
else
{
str=binaryStr;
}
str ="0"+str.trim();
int x=Integer.parseInt(str,2);
//x=x>>1;
respMsg += ""+(char)x;
}

}catch(Exception e){
System.out.println("error :"+e);
}

return respMsg;
}

public String hexToBinary(String hexString)
{
String binaryStr="";
int n=hexString.length();
if(n%2>0)
hexString +="0";
for(int i=0;i<n/2;i++)
{
String str="";
if(hexString.length()>2)
{
str=hexString.substring(0,2);
hexString=hexString.substring(2);
}
else
{
str=hexString;
if(str.length()<2)
str +="0";
}
binaryStr += Integer.toBinaryString(Integer.parseInt(str,16));

}

return binaryStr;
}

Regs,
Rishi Tyagi
13 years ago
Hi,
I am working on an application which require some files to be uploaded at the server through ftp.
How can we do that using java network programming.

is there any working example available on net?

Regards,
Rishi
Thanks William Brogden for your support.

Problem seems to be sorted out. Infact some of the jsp applications were creating problems.

Regards,
Rishi tyagi
14 years ago
Thanks William Brogden,

Infact increasing the memory in java_opts variable helps but not much. Still there is one problem:

After running for some time timcat hangs out, although it is not giving any error like out of memory or any other.
But it stops responding to the request.

What is the reason behind it and what is the solution for the same. Can you help on this .

Regards,
Rishi Tyagi
14 years ago
William Brogden ,
First of all i would like to say thanks for the answer.

Now let us come on the topic.
1- Connection Pool
Yes i am using one third party api rpDBPool.jar for implementation of connection pooling.

2- When does this problem occurs:
infact when i restart the tomcat it runs ok for some time. if there is less load on the applications then too it works fine. But problem occurs when load increases. You can say it happens with the 100th request.

One silly question i would like to ask that is : Is there any relationship between the max number of connections defined in the connection pool and the max number of processes in tomcat?

Infact when i increase the value of max processes in the <Tomcat Home Dir>/conf/server.xml file then the error occurs very frequently but when i put this value to 100 then frequency of the error decreases.
Some more questions i would like to ask about jakarta-tomcat server
1- Is there any possibility of cloning the jakarta-tomcat server to handle the load if it increases to the limit of one instance.
2- How can we increase the memory assigned to jvm running tomcat, i.e where can we use the -Xmx256m option in the configuration files.
3- Is there any good online document available for this server, which can help to study out this server deeply.
Regards,
Rishi Tyagi
14 years ago