varkala prabhakar

Ranch Hand
+ Follow
since Sep 08, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 varkala prabhakar

My table:
SlNo is an Integer and remaning all the feilds are Text. and Feild sizes are bigger then what is insert.
Hi,
I am new and i get SQLException. Please help me.
Here is my code & Exception
/********************************************************/
Exception :
E:\StreamDetails\program>java StreamDetails
InsertStr :
INSERT INTO StreamDetails1 (SlNo,Name,Codec,Level,Duration,VideoBitRate,VideoAspectRatio,FrameRate,AudioStandard,AudioBi
tRate,SamplingFreq,AudioDuration) VALUES (1,'Mask_av4570kbps_v4450kbps_NTSC_720x480_a120kbps_48khz_AAC_stereo.ProgDwnl.m
p4','MPEG-4 Simple ',' L3',' 248.541 secs',' 4457 kbps',' 720x480 ',' 24.000064 fps','MPEG-4 AAC LC',' 120 kbps',' 48000
Hz',' 248.533 secs')
SQLException : [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source)
at StreamDetails.main(StreamDetails.java:139)

E:\StreamDetails\program>



Code :
import java.sql.*;
import java.io.*;
import java.util.*;

public class StreamDetails {
public static void main(String args[])
{
String url = "jdbc dbc:STREAMS"; //"student is data source name"
Connection connect;
String createTableString;
Statement stmt;


String filename;
String codec;
String level;
String Duration;
String BitRate;
String AspectRatio;
String FrameRate;

String audioStandard;
String audiobitrate;
String samplingFreq;
String audioDuration;

/****************************************************/
/*JDBC ODBC CONNECTION*/
/****************************************************/

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try
{
InputFile in = new InputFile("E:\\StreamDetails\\Parsing\\OutPutFile.txt");
String s;
int i = 1;
connect = DriverManager.getConnection(url, "", "");
stmt = connect.createStatement();
StringTokenizer st ;
int StrInd=1;

while((s = in.getLine()) != null)
{
st = new StringTokenizer(s, ",");
StrInd=1;
while (st.hasMoreTokens())
{
filename =new String(st.nextToken());
codec = new String(st.nextToken());
level = new String(st.nextToken());
Duration = new String(st.nextToken());
BitRate = new String(st.nextToken());
AspectRatio = new String(st.nextToken());
FrameRate = new String(st.nextToken());
audioStandard = new String(st.nextToken());
audiobitrate = new String(st.nextToken());
samplingFreq= new String(st.nextToken());
audioDuration = new String(st.nextToken());
String InsertStr = "INSERT INTO StreamDetails1 (SlNo,Name,Codec,Level,Duration,VideoBitRate,VideoAspectRatio,FrameRate,AudioStandard,AudioBitRate,SamplingFreq,AudioDuration) VALUES ("+StrInd+",'"+filename+"','"+codec+"','"+level+"','"+Duration+"','"+BitRate+"','"+AspectRatio+"','"+FrameRate+"','"+audioStandard+"','"+audiobitrate+"','"+samplingFreq+"','"+audioDuration+"')";
System.out.println("InsertStr "+ ": \n" + InsertStr);
stmt.executeUpdate(InsertStr);

System.out.println("Insert Statement completed ");
StrInd++;
break;

}



}
in.cleanup();
stmt.close();
connect.close();

}
catch(SQLException ex)
{
System.err.println("SQLException : " + ex.getMessage());
ex.printStackTrace(System.err);
}
catch(Exception e) {
System.err.println("Caught in main, e.printStackTrace():\n");
e.printStackTrace(System.err);
}

}

}

/********************************************************/
/*READ THE INPUT FILE CLASS*/
/********************************************************/

class InputFile {
private BufferedReader in;
InputFile(String fname) throws Exception {
try {
in =
new BufferedReader(
new FileReader(fname));
// Other code that might throw exceptions
} catch(FileNotFoundException e) {
System.err.println(
"Could not open " + fname);
// Wasn't open, so don't close it
throw e;
} catch(Exception e) {
// All other exceptions must close it
try {
in.close();
} catch(IOException e2) {
System.err.println(
"in.close() unsuccessful");
}
throw e; // Rethrow
} finally {
// Don't close it here!!!
}
}
String getLine() {
String s;
try {
s = in.readLine();
} catch(IOException e) {
System.err.println(
"readLine() unsuccessful");
s = "failed";
}
return s;
}
void cleanup() {
try {
in.close();
} catch(IOException e2) {
System.err.println(
"in.close() unsuccessful");
}
}
}
/*********************************************************/
[ August 04, 2005: Message edited by: Bear Bibeault ]
Hi William,
Whether Form can be handled with out a submit button.
I should not have a submit button, Just a link and parameters should be hidden
Hi Bear Bibeault, I will check with your function.
thanks
prabhakar.
21 years ago
Hi all,
I my work, i get the url from the database and this is to be displayed as a link.I am using href for the link. When i click on the url, url parameters are displayed.
I cannot keep a submit button for the link to hide the parameters.
I want to hide the parameters, Can any one tell me how to hide the parameters.
thank you..
21 years ago
Hi,
In DriverManager.getConnection, we have three parameters..for URL,Login, Passwd.
Some time back, when i was using Oracle on 202.141.81.233 IP, the parameter is
jdbc racle:thin:@202.141.81.233:1521 ROJDB,"scott","tiger";

But now i am working with MS Access, and database is in computer name "cebgt068".
can any one tell me what should be the URL part to get the connection with the database.
thank you
prabhakar.
hai,
Can javadoc provides documentation for servlet programs. i need to generate documentation for my project done in servlets.How to do that??
waiting for a reply.
prabhakar.
22 years ago
Hai,
i dont understand how to solve my problem, retriving records comparing date will work for some records and for some records its not working. i get this problem from 3 days back and before that it used to work fine. i use oracle 8i in winnt server. I did not make any changes in oracle settings.
kindly reply
prabhakar.
Hai paulo,
you u have those are not working for me. and Java.util.Date allows JDBC to identify this as a SQL TIME value.
between operations works fine but when i compate for a particular date then i get no records.

SQL> select * from emp where hiredate between '1-JAN-02' and SYSdate;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
1154 kodati clerk 7839 15-JAN-02 2233 300
20

some more recors like
~~~~~~~~~~~~~~~~~~~~~~~~~
1151 mtadi clerk 7788 05-DEC-01 2140 300
20
1153 venkate analyst 2140 05-DEC-01 2000 20
20
1154 kodati clerk 7839 15-JAN-02 2233 300
20
when query the data base :
SQL> select * from emp where hiredate='05-JAN-01';
no rows selected
i get no results.

kindly suggest a solution soon, dead line is very nearer to submit my work.
regards
prabhakar.
In my table i have the date column and i am using the setting SYSDATE to enter the date in my oracle 8i table. and when i try to get he records using on date field i get
SQL> select * from moneytrans where DOT=sysdate;
no rows selected
SQL> select * from moneytrans where DOT='1-JAN-02';
no rows selected
even i used java Date
java.util.Date d = new Date();
query ="select * from moneytrans where DOT="+d+"";
ERROR:
~~~~~~
java.sql.SQLException: ORA-00933: SQL command not properly ended
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java)
at AdminTransaction.doGet(AdminTransaction.java:389)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at sun.servlet.http.HttpServerHandler.sendResponse(HttpServerHandler.java:165)
at sun.servlet.http.HttpServerHandler.handleConnection(HttpServerHandler.java:121)
at sun.servlet.http.HttpServerHandler.run(HttpServerHandler.java:90)
at java.lang.Thread.run(Unknown Source)

but my table contains the records on that date. Very urgent to submit my work reply me...
thanx
prabhakar.
Hai all,
I have made a package consisting of some classes of applet applications. When i tried to use that package in my program, compiling properly.
but while execution the applet doesn't get initialized and i get error that the package class file is not found.
when i tried this package method for small programs like addition,multiplicaion,(Non applet programs) it worked fine.
thanx
prabhakar.
22 years ago
hai,
I have a mail servlet and when i try to run that servlet i get this error:,kindly tell me how to correct the error.
thanx
prabhakar
code:

Added code UBB tags
-Mike C
[ January 07, 2002: Message edited by: Mike Curwen ]
22 years ago
Hai,
I have a oracle 8i database consisting of 10000 records in a table,
Now i have to check nearly more than the number of records wether the specified record is there in database or not.so what i do is every time i make the query and check in the database. Is there any method to reduce my program execution.
Even if i store table in temp array and check for the necessary condition, full array[1000][] have to be searched and i think the time taken to query the database and accessing the whole array will not make much difference.
hope for better suggestion from u all.
thanx
prabhakar.
hai bill,
the above given code is a trail. actually in my project with the available enterprise data i generate java class dynamically (used in data mining and intelligence part). this has to be complied and used in further comming request.
thanx
prabhakar
22 years ago
Hai,
In my work my servlet generates a java class file say "abc.java" , this java file have to be compiled at runtime and this compiled class has to be used in the further execution with out stopping my servlet runner.
this Generated "abc.java" may change in every request.
I am using servlet runner and java web server 2.0.
`````````````````````````````````````````````````````
Just to test this i have written a servlet testExe.java ,class getFileData.java ,GotoClass.java, WriteIntoFle.java
Initially i compile all of them and run the servlet, after that i make change in the GotoClass.java in str variable(now i don't compile it). and run the servlet.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class testExe extends HttpServlet{
public void init(ServletConfig config) throws ServletException {
super.init(config);
} // End of init()
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println(" <html><head><title> Hai</title></head><body>");
String str = " Hello";
out.println("<b>"+str+"</b><br>");
getFileData gt = new getFileData();

String data = gt.getfiledata();
System.out.println(" File Received to Servlet from getFileData:\n");
System.out.println(" Data:\n"+data+"\n Data Complete");
out.println("data printing :<br>"+data+"<br> Data printing Completed");

WriteIntoFile wf = new WriteIntoFile();
wf.writefile("GotoClass.java",data);
try{
Process p = Runtime.getRuntime().exec ("javac GotoClass.java");
System.out.println("Compiled");
p.destroy();
System.out.println("Operation Complete");
System.out.println(" Before the use of the class");
GotoClass gc = new GotoClass();
String str1 = gc.gotoclass();
out.println("<b>gc.gotoclass :"+str1+"</b>");
}//try
catch(IOException ioe){
ioe.printStackTrace();
}// catch
out.println("</body></html>");
out.close();
}// end of doGet()
}// end of class testExe
----------------------------------------------------------------
import java.io.*;
public class getFileData{
public String getfiledata(){
String retdata = null;
try{
System.out.println("\n\n Execution in getFileData:");
FileInputStream in = new FileInputStream("GotoClass.java");
InputStreamReader isr = new InputStreamReader(in);
int ch=0;
StringBuffer buf = new StringBuffer();
while((ch = in.read())> -1){
buf.append((char)ch);
System.out.print((char)ch);
}

System.out.println("\n\n");
retdata = buf.toString();
System.out.print("printing file :\n"+retdata+"\n Data Complete\n");
}
catch (IOException e){
System.out.println(e.getMessage());
}
System.out.println(" Termination of getFileData:\n\n");
return retdata;
}// end of method

}// end of class
----------------------------------------------------------------
import java.io.*;
import java.util.*;
import java.net.*;
public class WriteIntoFile {
public void writefile(String filename, String data){

System.out.println("\n\nExecution in WriteIntoFile:\n");
System.out.println("File name:\t"+filename+"\t \n Data received :\n"+data);
String pathname ="f:/mtp/temp/files/"+filename;
System.out.println(" Path name :\t "+ pathname);
File f = new File(pathname);
String s=null;
if(f.exists()){
System.out.println("File is all ready there");
f.delete();
f = new File(pathname);
try{
boolean created=false;
created=f.createNewFile();
System.out.println("After the File Creation");
}// end of try
catch(IOException ioe){
System.out.println("File Creation Error:\t\n");
ioe.printStackTrace();
}// end of catch
if(f.exists()){
String s1 = f.getAbsoluteFile().getName();
s = f.getName();
System.out.println(" File Name Created :\t"+ s);
System.out.println(" s1:\t"+s1);
s1 = f.getPath();
System.out.println(" Path of the file :\t"+s1);
System.out.println(" File Url Name:\t"+s1);
try{
FileWriter fw = new FileWriter(s);
String str = data;
fw.write(str);
fw.flush();
fw.close();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}// end of if exists
}// end of if(f.exists())

else {
try{
boolean created=false;
created=f.createNewFile();
System.out.println("After the File Creation");
}// end of try
catch(IOException ioe){
System.out.println("File Creation Error:\t\n");
ioe.printStackTrace();
}// end of catch
if(f.exists()){
String s1 = f.getAbsoluteFile().getName();
s = f.getName();
System.out.println(" File Name Created :\t"+ s);
System.out.println(" s1:\t"+s1);

try{
FileWriter fw = new FileWriter(s);
String str = data;
fw.write(str);
fw.flush();
fw.close();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}// end of if exists
}// end of esle if(f.exists())
System.out.println("\nTermination of WriteIntoFile file\n\n\n");
}// end of writefile method

}// end of class WriteIntoFile
----------------------------------------------------------------
import java.io.*;
import java.util.*;
public class GotoClass {
public String gotoclass(){
//String str =" Before making change, <b>Initially compiled<br></b><br>No change in execution";
String str = " After the compilation, <b>Compiled at runtime<br></b> Changes Done, Congrats";
return str;
}
}
--------------------------------------------------------------

thanx
prabhakar.
22 years ago
Hai,
With the received request, i generate a java file(java class) and wite it into a java file, Now i have to compile this program and i have to use in further comming request.
help me how to compile the generated java file and use that java class in further comming requests. I use java webserver 2 & servlet runner.
thanx
prabhakar.
22 years ago