Abhishek Mish

Greenhorn
+ Follow
since Dec 21, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
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 Abhishek Mish

Hi,
I am trying to execute shell script from java, the shell script interns call the sql file.
When shell script is called it connect to database sucessfully but when sql file is called it is giving below error.
SP2-0310: unable to open file ".sql".
When I run the line explicitly in cygwin it works fine.
sqlplus -s $DBConnect @test.sql. I even given the read/write/execute permission to the sql file still it is not working.
I know this query is not related to Java instead to shell scripting, but i didnt find the correct forum to post.

Thanks,
14 years ago
Thanks for responding..
I am able to run the script from Cygwin.
Is there any way where i can execute the shell script from java code in windows platform.

Thanks,
14 years ago
Hi All,
I am trying to execute shell script from java, code scippet is below

public class ExecuteSh{
public static void main(String[] args){
try{
String[] cmd = new String[2];
cmd[0] = "/bin/sh";
cmd[1] = "D:\\loading\\test.sh";
String execString = "D:\\loading\\test.sh" ;
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);
}
catch (Exception e){
e.printStackTrace();
}
}
}

I am getting below error
java.io.IOException: CreateProcess: \bin\sh D:\loading\test.sh error=3
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at Sh.main(Sh.java:9)

I also tried changing the cmd array to only sh script name, but still it is not working.
In my local dev enviornment OS is Windows XP.

Kindly suggest,
Thanks
14 years ago
Thanks Rob,
Its nice and informative info, I am sure it will definitely help me.
I will go through and will post if any problem i faced.

Thanks,
14 years ago
Hi All,
I need to execute a batch file from java, below is the code snippet

Runtime rt = Runtime.getRuntime();
Process pr=rt.exec("cmd /C start D:\\batchRun\\test.bat");
int exitValue=pr.exitValue();

I am able to successfully execute the batch file, but i have a few concerns,

1. Also when the batch is completed successfully i want to know if it there were any errors in the batch execution. I tried using
pr.exitValue() and pr.waitFor(), but in both cases, even if i explicity close the command propmt i still obtain exitValue as 0.
If there anyways where i can get to know whether batch file completed without errors.

2. How to execute batch file silently in the background without cmmmand prompt getting open. I removed cmd /C start and it works fine,
but this behaviour is not consistent in different OS.

Thanks,
14 years ago
Hi,
My requirement is that i need to redirect logs to two different log files of same class.
I had java class which had few log statement which needs to be redirect to different log files based on the requirement
which logs needs to be logged in which log files.

Thanks,
Hi All,
I am using openCsv to bind the csv content to java bean object.
Below is the code snippet,



Above code works fine if my bean class as below



But the problem if setCode of my bean class accept any other datatype other than String. If the getters/setters are changed as below



Then it throws exception while parsing csv file, does that mean it will work only for strings.

Thanks in Advance.
Hi All,
I need to open file in textpad using the below code as
private static final String ADDRESS_FILE="examples/addresses.csv";

Runtime.getRuntime().exec("notepad.exe " + ADDRESS_FILE);

I am facing few problems:

1. If i am trying to open file in textpad then i need to provide the full path of textpad exe instead if i am passing notepad exe then full path
of exe is not required. In that case i need to hard code the path of textpad exe.
2. Also multiple instance of notepad is opened everytime the above code got executed.

Thanks,
Abhishek
14 years ago
Hi All,
I need to generate the log file every time with dynamic log file name.
As per my understanding it cannot be done from log4.properties as the name of the file is constant which is defined in the properties file.
In that case i need to write the custom File appender which generates the log file with dynamic name.
Let me know if there is any other good way of doing and also provide me with some good sample example.

Thanks,
Paul and Rahul thanks for the suggestion.

Thanks,
Abhishek
Hi Rahul,
Thanks for the reply, even i thought of this solution but the biggest problem in that case is, if data are committed in batch with new transaction for every batch data instead of whole data getting commited in single transaction.
The problem is it will commit data partially if there is some exception scenario as every batch will have new transaction.
Please let me know if i understand correctly.

Thanks,
Abhishek
Thanks for the response..
I think what i understand is execuitng SQLLDR command from java class which will be faster.
But my concern is after executing sqlldr, I need to get the execution type so that i can show the message in the UI that it is successful or failed.
But still i think using this approach can add to lot of user firendly limitations.

Thanks,
Abhishek
Hi All,
My requirements is that i need to read a csv file which may contains huge data ie numbers of rows may be very huge.
After reading the file, I need to parse the file and do the validations based on some configuration which is stored in the database.
After suceesfull validation, I need to insert all the records in the database.
I think instead of commiting per data in a loop in a single transaction which can take long time and can cause the request time out or session time out as this will be synchronous request.
If data are commited in batch this can reduce the time as compared to per data basics. Commiting data in batch can also not confirm the request time out or session time out if size of the file is very huge. Also there is one more problem if few batch data are commited successful and with few batch there is some problem partial data will be commited as this is not done in single transaction.
Kindly suggest what would be the best possible solution to insert or update data in batch to avoid above mentioned problems.
Using ORM- EclipseLink(JPA) and Spring.

Thanks,
Abhishek
Thanks for responding..
I look at the various opensource api avialable, If performance is the bottleneck then which is the better way to do.
Using Java IO or using openCSV.

Thanks,
Abhishek
I would like to know if POI is able to read CSV files.
Although CSV files are text file which can be parsed/read using simple java.
Is there any open-source which provides api to read/parse csv file.
OpenCSV is one of the open-source api which provides api to parse and bind data to beans which can be saved to the database.
Please provide info if there is any another good way to parse csv file validate data and saved to the database.

Thanks,
Abhishek