Home » Open Source » Programming Interfaces » Need help VERY BADLY (Oracle 10g, WIndows XP)
Need help VERY BADLY [message #546758] Thu, 08 March 2012 10:18 Go to next message
Sravanthiwantshelpnow
Messages: 1
Registered: March 2012
Junior Member
Hello everyone, I badly need help with this code.. Below is a sample file attached (Which will be uploaded by the end user, as an external CSV file) which contains my actual data which needs to be uploaded to a database table.. As can be observed , the file requires pattern matching to be uploaded to a table..as the values after the "=" are to be considered.. Using JDBC connectivity, we have developed the code as follows to upload to the table respectively.. But the data is uploaded only upto 500 records..and the later ones are not uploaded..plz help..the code is as follows..


<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="javax.servlet.ServletException" %>
<%@ page import="javax.servlet.http.HttpServlet" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.http.HttpServletResponse" %>

<% int i,p=0,q=0,a,b,c,d,e,f,n=0,k=0,l=0;
String r,code;
String avi;
String str1;
String str2;
String str3;
String name=request.getParameter("datafile");

String data[]=new String[4000];
String data1[]=new String[4000];
String data2[]=new String[4000];
out.println(name);
FileInputStream in = new FileInputStream(name);
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hems","1367621213");
conn.setAutoCommit( false );
Statement stmt=con.createStatement();
BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
String strLine;
while ((strLine = br.readLine())!= null)
{


if(strLine.startsWith("@"))
{
a=strLine.indexOf("=");
b=strLine.indexOf(">");
c=strLine.indexOf("<");
d=strLine.indexOf("-");

code=strLine.substring(c+1,d);

if(code.equals("M02m00")) // for air temp level1
{

if(!(a<0))
{
i=0;
String line=strLine.substring(a+1,b);
StringTokenizer st = new StringTokenizer(line,"=,>");
while(st.hasMoreTokens())
{

data1[i]=st.nextToken();

i++;


}
}
}
if(code.equals("M02m02")) // airtemp level 2
{

if(!(a<0))
{
i=0;
String line=strLine.substring(a+1,b);
StringTokenizer st = new StringTokenizer(line,"=,>");
while(st.hasMoreTokens())
{
data[i]=st.nextToken();
i++;


}
}
}
if(code.equals("M02m04")) // for airtemp level3
{

if(!(a<0))
{
i=0;
String line=strLine.substring(a+1,b);
StringTokenizer st = new StringTokenizer(line,"=,>");
while(st.hasMoreTokens())
{
avi=st.nextToken();
data2[i]=st.nextToken();

i++;
n++;

}

}
}
out.println(n);

}

while(k<n)
{
str1=data1[k];
str2=data[k];
str3=data2[k];
out.println(str1);
ResultSet Rs1=stmt.executeQuery(" Insert /*+ APPEND_VALUES */ into AIRTEMP(LEVEL1,LEVEL2,LEVEL3) values('"+str1+"','"+str2+"','"+str3+"')");
k++;

}
}


%>
  • Attachment: 11051608.TXT
    (Size: 750.25KB, Downloaded 339 times)
Re: Need help VERY BADLY [message #546760 is a reply to message #546758] Thu, 08 March 2012 10:23 Go to previous message
BlackSwan
Messages: 22728
Registered: January 2009
Senior Member
It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
Previous Topic: PHP insert or update nvarchar2
Next Topic: JDBC Connection problem on Windows 2008 R2
Goto Forum:
  


Current Time: Tue Sep 02 21:27:40 CDT 2014

Total time taken to generate the page: 0.13784 seconds