• Post Reply Bookmark Topic Watch Topic
  • New Topic

Conversion of String into Bytes array and vice versa  RSS feed

 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
I have swing application which is running in tokyo but the database is in USA. So while sending string to store into database, over a WAN slow down the application performance. I have a quick if i convert all string into bytes of array before sending data into database and store bytes into Database instead of String, over WAN, is this efficient means if i go in this direction is this increase the performnce of my application. On other hand this reduce the time of sending byte as compare to String.

Please help me in this regards
I am very thankful to you.

best regards
ghaznafar
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on how you're sending the Strings now, I suppose. Unless you're deliberately doing something strange, you're probably already sending only the bytes needed to represent the array of characters.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you thinking of converting from unicode to plain ascii to cut the number of bytes down? Do you have Java-to-Java communication over the wire or a database connection?
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all thanks for all to reply me, yes Stan, i have java to java communication, but my client need speed. So if i use the application in chicago it is efficient but over the wire when i send strings like someone fill out the forms and so on, so its speed decreases and it is not effiecient enough, so i think it is because i am sending string to database might be that is the reason, i am not expereince guy, so i think if i convert all strings into bytes might this increase the system efficiency.

Please advice me in this regards
thanks
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing i left is that while filling out the forms, i am taking infroation as a string and it will sotre into 5 different table of database, so sending information is back and forth over the wire, is there any other way around but the thing is that i can not store whole information into one table here i can not compromise, so please suggest me something good i really appreciate.
thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still haven't told us what you're currently doing, so it's hard for us to tell you what might be better!
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are the details, I am taking stock report information of the whole day from tokyo office in which the person have to fill out some forms(windows). About the whole day progress and submit this information but the haed office is located in USA, so the Database and everything is reside in USA. So the person in Tokyo when hit the submit button it calls 5 insert statements to insert the data into 5 different table of database (call these insert statement one by one). So 5 times the information travel over WAN and the information contains String.

So this is taking time like 10 to 15 seconds, but if the same application run from USA then it take not more than 2 seconds or less.
So i think if i send information as bytes instead of sending String might get increase the performance of my application.


Thanks for all you who replied me.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but HOW do those strings travel? Inside the database driver? If so, what technology does the driver use? RMI? CORBA? Raw sockets and the database's native wire protocol?

Or do the Strings travel as part of an HTTP request/reponse? Or via application-level RMI, CORBA, raw sockets?

Unless you actually tell us physically how the data is being transmitted now, we can't tell you if there's a better way or not!
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ernest,
database's native wire protocol

thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the first thing you'd have to do, then, would be to introduce a middle tier running in the USA. Then you can optimize the communications between the middle tier and the client. Right now, aside from tunneling the connection through a link that compresses the data for transmission, there isn't anything you can do, since you don't control the protocol, right?
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right, can you please emphasis "middle tier".
thanks for your reply.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "middle tier" I mean an application server in the USA, connected in between the Tokyo application and the database. The Tokyo application talks to the middle tier in the most efficient way possible, and the middle tier talks to the database. The middle tier might just be a simple servlet running in Tomcat.

So it seems to me that you said the same data is inserted in five different tables. Does that mean the data travels over the network five times? Then you could send the data once to the middle tier over the WAN, and then the middle tier could quickly insert it into the database over its LAN connection to the database. This could be five times faster already!
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very Ernest, I will start looking in this direction now. thanks again
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!