Click here to Skip to main content
15,886,689 members
Home / Discussions / Java
   

Java

 
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 
GeneralRe: how to print the fullstr string to a text file. Pin
Richard MacCutchan16-Aug-16 2:58
mveRichard MacCutchan16-Aug-16 2:58 
Questionneed to print the fullstr string to a textfile Pin
Member 1142765716-Aug-16 0:31
Member 1142765716-Aug-16 0:31 
QuestionDuplicate entry 'VALUE' for key 'PRIMARY' Pin
Django_Untaken13-Aug-16 9:54
Django_Untaken13-Aug-16 9:54 
AnswerRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Patrice T13-Aug-16 16:59
mvePatrice T13-Aug-16 16:59 
GeneralRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Django_Untaken14-Aug-16 3:28
Django_Untaken14-Aug-16 3:28 
GeneralRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Patrice T14-Aug-16 3:39
mvePatrice T14-Aug-16 3:39 
Question[SOLVED] java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Pin
Django_Untaken4-Aug-16 8:35
Django_Untaken4-Aug-16 8:35 
AnswerRe: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Pin
Richard MacCutchan4-Aug-16 20:38
mveRichard MacCutchan4-Aug-16 20:38 
QuestionMaven cmd line Tests failing,M aven Test Run Through Eclipse Pass Pin
DLamar123-Aug-16 8:29
DLamar123-Aug-16 8:29 
AnswerRe: Maven cmd line Tests failing,M aven Test Run Through Eclipse Pass Pin
jschell12-Aug-16 10:54
jschell12-Aug-16 10:54 
Questionread and traverse over the TTL file Pin
Eng.Roqaya22-Jul-16 8:12
Eng.Roqaya22-Jul-16 8:12 
AnswerRe: read and traverse over the TTL file Pin
Richard MacCutchan22-Jul-16 21:25
mveRichard MacCutchan22-Jul-16 21:25 
Question.jar to .exe Pin
prateek chauhan19-Jul-16 18:47
prateek chauhan19-Jul-16 18:47 
AnswerRe: .jar to .exe Pin
Richard MacCutchan19-Jul-16 21:48
mveRichard MacCutchan19-Jul-16 21:48 

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.