Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!

Rohit Dhodapkar

Ranch Hand
+ Follow
since Apr 27, 2006
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 Rohit Dhodapkar

Hi Guys,

We are currently using Struts 1.2.4 (struts.jar) and Jdk 1.3.1. The struts.jar was compiled used jdk 1.4. This information I got from manifest.mf file.

We are now planning to move our application to Java 5. But we would like to retain the version of struts we are using.
Can we use the same struts.jar file or is there a struts 1.2.4 jar available for Java 5?

Regards
10 years ago
Thanks sagar, but the document you suggested uses distributed transaction using application server. I am running stanalone batch job. Is there any way of handling distributed transaction then?
Hi All,

I have developed standalone program which talks to two different oracle databases. As the program is small it doesn't require a application server to run on. The sql inserts on two different oracle database should happen in a trasaction. I won't be able to use sophisticated JTA or EJBs as they run inside container. I am left with using JDBC transactions. I am aware that JDBC transactions aren't distributed. Please can somebody suggest any way of achiving distributed transaction behaviour with JDBC?

Cheers,
Rohit
Hi,

I would like to have your suggestions on this. I have a database table with 3 million Credit Card numbers. The requirement is to encrypt all the 3 million cards. So I have to retrive card number encrypt it and update it on the table. Can anybody suggest the safest and most efficient way of doing this? Should I use EJBs or simple JDBC calls would be good enough. I am using oracle database.

Thanks,

Rohit
William,

I am trying to use java.util.regex package..
My Code looks like this :

String testName = "Rohit�s"
Pattern p = Pattern.compile("�");
Matcher m = p.matcher(testName);
if(m.find())
{
testName = m.replaceAll("'");
}
The output is Rohit's which is correct.

The thing is that if I have multiple different special characters which can appear in string testName randomly but do not make a specific pattern Iam not able to replace them all.
Ex..

String testName = "�Rohit�s"
Pattern p = Pattern.compile("��");
Matcher m = p.matcher(testName);
if(m.find())
{
testName = m.replaceAll("'");
}
The output is �Rohit's which is incorrect but the output should be 'Rohit's.

Thanks in advance..
13 years ago
JSP
Hi,

I guess you should'nt bring the Result Sets in JSP and iterate them there. This is not a good practice. YOu should store the contains of the result sets in different Java Bean objects. And then iterate the beans in JSPs. This follows as Transfer Object and Value Object Pattern in J2ee design Patterns.

I guess you should disconnect the resultset first and then send it to JSPs if you want you current model to work to avoid Runtime exception .
Thanks William and Paul .. I will try your solution and let you know if I still face any problem ..
13 years ago
JSP
Iam doing the following steps :

I copy text (For Example: JOHN's) containing a apostrophe from the Microsoft Word document and paste it in a JSP Text box rather then righting JOHN's directly in the text box.

Then submit the jsp so that value in the text box gets entered into the database table .

Now what I am finding gets entered in the table is JOHN�s . So the apostrophe gets converted to � .

I dont know why this is happening or how to resolve this..Please help me regarding this..
[ December 01, 2006: Message edited by: Ben Souther ]
13 years ago
JSP
Hi Prabu,

Can you please explain what to do to make sure that the main thread finshes its execution only after the thread in the code???
Hi Henery,

That clarifies my doubt . final variable are compile time constants.
I noted if we remove the final from
private final int size;

The result is - 10 .

Thanks for that.
Hi Saurabh,

Coming to the third case ie
quote:
public static final SizeClass INSTANCE = new SizeClass(10);
private static final int MAX_SIZE = 1000;
Here again the initialization from top to bottom rule applies but with a small change. Since MAX_SIZE is assigned with a finite value rather than some method call initialization, so it will be initialized before INSTANCE. Thus again the o/p will be "Size is 990".


By the above statement do you mean in case when a finite value is assigned to a static final vaiable then the top to bottom rule of initialization is not applicable. Because if it is applicable there would be still forward referencing in the constructor.. Please explain
Its because
1. Thread a and b both are created by the same object .
2. THe run method is syncronized.
So in your code thread a enters into a infinite for loop and never finshes. So thread b can't enter the run method.

Try this code. It would be more clear

public class RunnableTest implements Runnable{
static int x, y;
public synchronized void run(){
for(int i= 0 ;i<100 ;i++) {
x++;
y++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(x+" "+y + " " + Thread.currentThread().getName());
}
}
public static void main(String[] args) {
RunnableTest runnable = new RunnableTest();
Thread a = new Thread(runnable);
a.setName("a");
Thread b = new Thread(runnable);
b.setName("b");
a.start();
b.start();
}
}
Can we have security contraints applied to a folder in a webapp deplyed on Weblogic app server.
My web app structure is as below
MyWebApp
|
|
| - first.jsp
| - second.jsp
| - /reports
|
| - third.jsp
| - fourth.jsp

Can I restrict reports folder to allow access only to user belonging to a particular role. Security constraint element which defines this in the web.xml is given below.

<security-constraint>

<web-resource-collection>

<web-resource-name>entireWebSite</web-resource-name>
<description>protects the entire web site.</description>
<url-pattern>/reports/*</url-pattern>
</web-resource-collection>

<auth-constraint>
<role-name>PARS_Giro_Recon_Mngr</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>

</security-constraint>

When I access the page it gives a page not found error.
13 years ago
Can we have security contraints applied to a folder in a webapp deplyed on Weblogic app server.
My web app structure is as below

Can I restrict reports folder to allow access only to user belonging to a particular role. Security constraint element which defines this in the web.xml is given below.

<security-constraint>

<web-resource-collection>

<web-resource-name>entireWebSite</web-resource-name>
<description>protects the entire web site.</description>
<url-pattern>/reports/*</url-pattern>
</web-resource-collection>

<auth-constraint>
<role-name>PARS_Giro_Recon_Mngr</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>

</security-constraint>

When I access the page it gives a page not found error.

[BPS: Added ubb code tags to dir structure]
[ September 29, 2006: Message edited by: Ben Souther ]
13 years ago
The first thing you need to do is to get all data (rows) which you want to insert into your servlet.
For example on JSP each row has two text box which can be updated.

1. First Name
2. Surname

Now in the JSP make sure that the name of name and the surname text box is same for each row .Doing so you would be left with two arrays of text box. One for name and one for surname.

On the Servlet
use

String[] name = request.getParameterValues("name");
String[] surname = request.getParameterValues("surname")
Emolyee emp = null; // Mabe a bean which have getter and setter for name and surname

ArralList list = new ArrayList();
for(int i = 0 ;i<name.lenght;i++) {
emp = new Employee();
emp.setName(name[i]);
emp.setSurname(surname[i]);
list.add(emp);
}

Now pass this list to you database class.
There loop through the list and make dynamic insert statements

like

for(int k = 0;k<list.size();k++) {
insert into emp values(list.get(k).getName(),list.get(k).getName())
}
13 years ago