Tell me about exec(),biojava...,how to connect database written in c executable file?
sameer ingle
Greenhorn
Joined: May 10, 2001
Posts: 2
posted
0
problem that i am faceing is that..i have to run about 50mb to 1 gb database using java ..database in in c(executable flatfile)... it run fine for same databse around 1-10mb.. for bigger databse it is hang... code i written is//// import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Hello World. This servlet simply says hi. * * <P> This is useful for testing the servlet configuration process, * since this servlet isn't installed. */ public class FastaEngine extends HttpServlet { public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out;
res.setContentType("text/html"); out = res.getWriter();
String source=req.getParameter("S1"); String v =req.getParameter("libpo"); String databasename =req.getParameter("program"); //String v =req.getParameterValues("libpo"); out.println("<b>Getting the value from text box</b>"); out.println("<H1>"+v+"</H1>"); out.println("<H1>"+databasename+"</H1>"); //building string From various Option //String command="D:/jithesh/sameer/"+databasename+" - "+ v+" ecoli3.txt ecoli3.txt"; String command="D:/jithesh/sameer/fasta -Q -O output d:/javaproject/ecoli3.txt d:/javaproject/mito.nt"; //D:\\jithesh\\sameer\\Fasta -q -o output salmo.txt swissport out.println(command); Date dd1=new Date(System.currentTimeMillis()-24*60*60*1000); out.println("Time Started:"+dd1); GregorianCalendar gc1 = new GregorianCalendar(); Date d1 = gc1.getTime(); long l1 = d1.getTime(); /* TAKING QUERY STRING FROM THE TEXT BOX AND WRITING TO THE FILE OF NAME DEMO.TXT CODE BEGAIN */ char buffer[]=new char[source.length()]; source.getChars(0,source.length(),buffer,0); //FileReader fr =new FileReader("d:/javaproject/ShowFile.java"); FileWriter wr =new FileWriter("c:/demo2.txt"); for(int i=0;i<buffer.length;i++){ wr.write(buffer[i]); } wr.close(); //CODE OF FILE WRITING END.
//Executing The File And Reading the File //get Runtime it return the proccess Runtime rt=Runtime.getRuntime(); //executing the exe file. //Process pro=rt.exec("D:/jithesh/sameer/Fasta -o ecoli3.txt ecoli3.txt"); Process pro=rt.exec(command); //reading the file content in byte stream out.println("Executed");
InputStreamReader isr=new InputStreamReader(pro.getInputStream()); //Storing in the bufferreader. BufferedReader br= new BufferedReader(isr); String line; //Reading the output Content... while((line=br.readLine())!=null) // out.println("<br>"+line+"</br>"); out.println("<font color=red><font size="+"1"+">"+"<br>"+line+"</font></br></font>"); GregorianCalendar gc2 = new GregorianCalendar(); Date d2 = gc2.getTime(); long l2 = d2.getTime(); long difference = l2 - l1; out.println("Elapsed milliseconds: " + difference);
out.println("<b>"+"Hello World sameer ....."+source+"</b>"); out.println("<p><a href="+"http://localhost:8080/servlet/FastaOutput"+">see Result of Fasta Engine.....</a></p>"); out.println("</body></html>"); // res.sendRedirect("http://localhost:8080/servlet/RedirectServlet"); Date dd2=new Date(System.currentTimeMillis()-24*60*60*1000); out.println("<br>TimeComPleted"+dd2+"</br>"); out.println("<br>Elapsed milliseconds: " + difference+"<br>"); } } import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Hello World. This servlet simply says hi. * * <P> This is useful for testing the servlet configuration process, * since this servlet isn't installed. */ public class FastaEngine extends HttpServlet { public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out;
res.setContentType("text/html"); out = res.getWriter();
String source=req.getParameter("S1"); String v =req.getParameter("libpo"); String databasename =req.getParameter("program"); //String v =req.getParameterValues("libpo"); out.println("<b>Getting the value from text box</b>"); out.println("<H1>"+v+"</H1>"); out.println("<H1>"+databasename+"</H1>"); //building string From various Option //String command="D:/jithesh/sameer/"+databasename+" - "+ v+" ecoli3.txt ecoli3.txt"; String command="D:/jithesh/sameer/fasta -Q -O output d:/javaproject/ecoli3.txt d:/javaproject/mito.nt"; //D:\\jithesh\\sameer\\Fasta -q -o output salmo.txt swissport out.println(command); Date dd1=new Date(System.currentTimeMillis()-24*60*60*1000); out.println("Time Started:"+dd1); GregorianCalendar gc1 = new GregorianCalendar(); Date d1 = gc1.getTime(); long l1 = d1.getTime(); /* TAKING QUERY STRING FROM THE TEXT BOX AND WRITING TO THE FILE OF NAME DEMO.TXT CODE BEGAIN */ char buffer[]=new char[source.length()]; source.getChars(0,source.length(),buffer,0); //FileReader fr =new FileReader("d:/javaproject/ShowFile.java"); FileWriter wr =new FileWriter("c:/demo2.txt"); for(int i=0;i<buffer.length;i++){ wr.write(buffer[i]); } wr.close(); //CODE OF FILE WRITING END.
//Executing The File And Reading the File //get Runtime it return the proccess Runtime rt=Runtime.getRuntime(); //executing the exe file. //Process pro=rt.exec("D:/jithesh/sameer/Fasta -o ecoli3.txt ecoli3.txt"); Process pro=rt.exec(command); //reading the file content in byte stream out.println("Executed");
InputStreamReader isr=new InputStreamReader(pro.getInputStream()); //Storing in the bufferreader. BufferedReader br= new BufferedReader(isr); String line; //Reading the output Content... while((line=br.readLine())!=null) // out.println("<br>"+line+"</br>"); out.println("<font color=red><font size="+"1"+">"+"<br>"+line+"</font></br></font>"); GregorianCalendar gc2 = new GregorianCalendar(); Date d2 = gc2.getTime(); long l2 = d2.getTime(); long difference = l2 - l1; out.println("Elapsed milliseconds: " + difference);
out.println("<b>"+"Hello World sameer ....."+source+"</b>"); out.println("<p><a href="+"http://localhost:8080/servlet/FastaOutput"+">see Result of Fasta Engine.....</a></p>"); out.println("</body></html>"); // res.sendRedirect("http://localhost:8080/servlet/RedirectServlet"); Date dd2=new Date(System.currentTimeMillis()-24*60*60*1000); out.println("<br>TimeComPleted"+dd2+"</br>"); out.println("<br>Elapsed milliseconds: " + difference+"<br>"); } }
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Tell me about exec(),biojava...,how to connect database written in c executable file?