prateek sharmaa

Ranch Hand
+ Follow
since May 15, 2010
Merit badge: grant badges
For More
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
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by prateek sharmaa

Hi all,
This question may sound stupid but I am stuck at it.

I have two projects in my workspace.
(1) core
(2) web

I have created a servlet in core project with name ShowDashboardServlet.java
In my web project I want to configure web.xml to point to TestServlet.java

Below mapping is done in web project's web.xml.



I want to do this because we want the URL to look like /web/dashboard/myproject and not /core/dashboard/myproject
and I can not put the servlet in web project as there are no servlet related jars available and few more jars that I use in the servlet are missing in web project.

so my restriction is that i need to keep the servlet in core folder and need to configure it in web project.

can I do this?
11 years ago
thanks a lot guys. now i am clear about how string objects are created

thanks,
Pratz
12 years ago
ok, my mistake
so now can i say that there will be 2 objects in memory after execution of below line?



one is String literal and other is new String object. right?
12 years ago
thanks Stephan, that was very much explanatory.

i have one more question that you said String literals are created at the time of class loading so shouldn't we count it as an object?

thanks,
Pratz
12 years ago
hi all,
i have a doubt in string concatenation.

1) how many strings will be created when below line is executed?


will the system create a string literal "abc" and then a string object on literal "abc"? so will system create 2 strings?

2)how many Strings will be created when below line is executed?



it will be good if anyone can give little explanation on how the strings will be created.
thanks.

regards,
Pratz
12 years ago
hi Tom,
in such a case i would create two properties files out of which first property file will remain at the same location and will contain location of second property file. now using first property file you can get the location and using Java and first property file you can get location of second property file and read the properties inside second property file.
now whenever user changes location of the second file he has to change location property in first property as well.
i know this is not the best practice and there could be some other way as well but this is what comes to my mind.

thanks,
pratz
12 years ago
hi sam,
thanks for the reply. your doubt was right. my TransferService class(in which transferMoney() method was there) was not under control of Spring. i have defined TransferService class as @Service and now its working

thanks,
pratz
12 years ago
Does anyone has any idea about this? Please help.
12 years ago
hi all,
i am trying to learn spring transaction. i am using jdbcTemplate for setting up connection but @Transactional(rollbackFor=Exception.class) does not seem working as it is not rolling back the data.
to give an overview i have written two methods. one method will reduce some amount from one row and other method will increase the amount in other row. i am calling both the methods from one single method and annotated that single method with @Transactional(rollbackFor=Exception.class) as mentioned below.

i am already having accountDao object so please don't worry about that.



now i am calling creditInToAccount method first and debitFromFromAccount next to it. in my debitFromFromAccount method i am throwing an Exception which should actually rollback the result of query executed in creditInToAccount but rolling back of creditInToAccount is not happening.
i check javaranch for the same and came across below mentioned thread
https://coderanch.com/t/572768/Spring/Rollback-not-working-Transactional#2605624
but in this link it is mentioned to set autocommit as false but i dont know how to do the same when using jdbcTemplate.

below is the snippet of xml that i am using for configuration



please help.

thanks,
pratz
12 years ago
hey peter,

Peter Johnson wrote:Oracle doesn't like the SQL statement (line 08) that you are passing to it. Have you tried running that command using Oracle command line SQL interpreter?



i tried running exec plandatacsv; using sqlplus and it executed successfully. may be there is some other way to do it using ant. do you have any idea?

thanks,
pratz
12 years ago
hello everyone,

i am writing an ant target to execute pl/sql procedure which is as follows



running the ant target throwing below error

exportSizeRatio:
[sql] Executing commands
[sql] Failed to execute: exec plandatacsv
[sql] java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
[sql] 0 of 1 SQL statements executed successfully

can anyone please help?

thanks,
pratz
12 years ago

Mark Spritzler wrote:

prateek sharmaa wrote:ok so do you mean to say that you will NEVER use scope="prototype" property in your bean configuration?

thanks,
pratz



never is a harsh word, but yes I try to avoid using it unless absolutely necessary, and I have yet to come across a situation/use case where I needed that.

Mark



oh ok fine.

thanks,
pratz
12 years ago
thanks a lot sudheer. it worked
hi ankit,

you can do following two things :

// Get the data from the row using the column index
String s = rs.getString(1);

// Get the data from the row using the column name
s = rs.getString("col_string");

if you know the next column number then you can use the first option or if you know the next column name you want to fetch then you can use the second option.

thanks,
pratz

ok so do you mean to say that you will NEVER use scope="prototype" property in your bean configuration?

thanks,
pratz
12 years ago