Click here to Skip to main content
15,914,642 members
Home / Discussions / Java
   

Java

 
AnswerRe: Exposing API VS Stored procedure Pin
Richard MacCutchan31-Aug-16 4:43
mveRichard MacCutchan31-Aug-16 4:43 
QuestionCan not Access RequestAttribute in JSTL Pin
AmbiguousName26-Aug-16 0:46
AmbiguousName26-Aug-16 0:46 
AnswerRe: Can not Access RequestAttribute in JSTL Pin
rah_sin30-Aug-16 20:07
professionalrah_sin30-Aug-16 20:07 
Question[SOLVED] 'TYPE' Cannot Be Resolved To a Type in JSP Pin
Django_Untaken24-Aug-16 2:34
Django_Untaken24-Aug-16 2:34 
QuestionDrools : Exception in thread "main" java.lang.RuntimeException: Query 'results' does not exist Pin
coolSol23-Aug-16 18:37
coolSol23-Aug-16 18:37 
AnswerRe: Drools : Exception in thread "main" java.lang.RuntimeException: Query 'results' does not exist Pin
Richard MacCutchan23-Aug-16 21:02
mveRichard MacCutchan23-Aug-16 21:02 
Questionconsole output to a text file Pin
Member 1142765722-Aug-16 3:55
Member 1142765722-Aug-16 3:55 
AnswerRe: console output to a text file Pin
Richard MacCutchan22-Aug-16 4:28
mveRichard MacCutchan22-Aug-16 4:28 
Rant[REPOST] console output to a text file Pin
Richard Deeming22-Aug-16 4:31
mveRichard Deeming22-Aug-16 4:31 
QuestionShould I use Java over Python for developing web application? Pin
Rebecca199521-Aug-16 12:20
Rebecca199521-Aug-16 12:20 
AnswerRe: Should I use Java over Python for developing web application? Pin
Richard MacCutchan21-Aug-16 23:02
mveRichard MacCutchan21-Aug-16 23:02 
AnswerRe: Should I use Java over Python for developing web application? Pin
manjiriV23-Aug-16 1:56
manjiriV23-Aug-16 1:56 
GeneralRe: Should I use Java over Python for developing web application? Pin
Rebecca199523-Aug-16 4:18
Rebecca199523-Aug-16 4:18 
GeneralRe: Should I use Java over Python for developing web application? Pin
Kofi_Tommy26-Aug-16 13:44
Kofi_Tommy26-Aug-16 13:44 
AnswerRe: Should I use Java over Python for developing web application? Pin
jschell1-Sep-16 6:56
jschell1-Sep-16 6:56 
QuestionHow Android derives from Java Pin
Andy_Bell18-Aug-16 6:34
Andy_Bell18-Aug-16 6:34 
AnswerRe: How Android derives from Java Pin
Richard MacCutchan18-Aug-16 22:27
mveRichard MacCutchan18-Aug-16 22:27 
GeneralRe: How Android derives from Java Pin
Andy_Bell18-Aug-16 23:04
Andy_Bell18-Aug-16 23:04 
GeneralRe: How Android derives from Java Pin
Richard MacCutchan18-Aug-16 23:26
mveRichard MacCutchan18-Aug-16 23:26 
Questionhow to write the console output to text file? Pin
Member 1142765718-Aug-16 0:29
Member 1142765718-Aug-16 0:29 
AnswerRe: how to write the console output to text file? Pin
Richard MacCutchan18-Aug-16 0:36
mveRichard MacCutchan18-Aug-16 0:36 
Generalhow to print the fullstr string to a text file. Pin
Member 1142765716-Aug-16 0:39
Member 1142765716-Aug-16 0:39 
public class sampl{
private static final boolean Null = false;
static String store = null;
static String ip = null;
static String port= null;
static String username = null;
static String password = null;
static String sid = null;
static String get = null;
static String s;
static String v="success";
static String sa = null;
static String fullstr = null;
String[] spl= null;
int i = 0;

public static void main(String[] args) throws FileNotFoundException {
{

String csvFile = "C:\\purge_test\\sam.csv";
BufferedReader br = null;
String line =null;
String cvsSplitBy = ",";
String[] spl= null;
String detail[]=null;


try {

br = new BufferedReader(new FileReader(csvFile));

// System.out.println("*****");

while ( (line = br.readLine() ) != null) {

// System.out.println("inside");
// use comma as separator
detail = line.split(cvsSplitBy);

// System.out.println("server ip = " + detail[1] +"\tport = " + detail[2] + "\tUsername"+ detail[3]+"\tPassword = "+ detail[4]+"\tSID = "+ detail[5]);
try{
store =detail[0];
ip = detail[1];
port= detail[2];
username = detail[3];
password = detail[4];
sid = detail[5];



int po = Integer.parseInt(port);

//step1 load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");

String a = "jdbc:oracle:thin:@"+ip+":"+po+":"+sid;
// System.out.println("string a:" + a);
// System.out.println("usrname:"+username);
//.out.println("pswd:"+password);


//step2 create the connection object
Connection con=DriverManager.getConnection(a,username,password);


// Connection con=DriverManager.getConnection(
// "jdbc:oracle:thin:@172.26.64.50:1521:xe","OATXPRESS","Ckpoatorapw1234");
//
//
//System.out.println("qqqq");

//Connection con=DriverManager.getConnection("a",username,password);

//step3 create the statement object
Statement stmt=con.createStatement();

// System.out.println("rrrr");

// java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
//step4 execute query
ResultSet rs=stmt.executeQuery("select TASK_NAME,to_char(START_TIME,'DD-MON-YYYY HH24:MI:SS') as RUN_TIME,case when count(*) > 0 then 'Task Initiated' else 'Task Not Initiated' end as \"TASK_Status\" from TMS_TASK_LOG where (TASK_NAME='purge_database' or TASK_NAME='db_stats_collection') and to_char(START_TIME, 'DD-MON-YYYY')=TO_CHAR(SYSDATE, 'DD-MON-YYYY') group by TASK_NAME,START_TIME ");
//File file = new File("C:/purge_test/tr.txt");

// ResultSet rs=stmt.executeQuery("select TMS_TASK_LOG_ID,TASK_NAME,START_TIME,STATUS from TMS_TASK_LOG where TASK_NAME = 'purge_database' AND ROWNUM < = 1 order by 1 desc");


if(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" ");

/*System.out.println(rs.getString(1)+" ");
System.out.println(rs.getString(2)+" ");

System.out.println(rs.getString(3)+" ");


//System.out.println(rs.getString(4)+" ");

Date d = new Date();
System.out.println("date "+d);*/

String fullstr =rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" ";

System.out.println("**********"+fullstr);


//__________________________
FileWriter fw = new FileWriter("C:/purge_test/foooooo.txt");

for (int i = 0; i < 10; i++) {
fw.write("something:\t"+ fullstr);
}

fw.close();

System.out.println("****00000******"+fullstr);
}


System.out.println("Done for store :"+store);




//step5 close the connection object
con.close();



}catch(Exception e){ System.out.println(e);}





}



} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

finally {

if (br != null) {
try {

br.close();

} catch (IOException e) {
e.printStackTrace();
}
}
}

}
GeneralRe: how to print the fullstr string to a text file. Pin
Member 1142765716-Aug-16 0:44
Member 1142765716-Aug-16 0:44 
GeneralRe: how to print the fullstr string to a text file. Pin
Richard MacCutchan16-Aug-16 1:22
mveRichard MacCutchan16-Aug-16 1:22 
SuggestionRe: how to print the fullstr string to a text file. Pin
Richard Deeming16-Aug-16 2:10
mveRichard Deeming16-Aug-16 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.