onlymullapudi
04-22-2006, 05:28 PM
Hai i want to know how to retrieve the clob fields from a table(i am using oracle 10g). I am able to insert a video file in to the clob field of the table, but unable to retrive, it is telling general error.
when i am trying to retrieve the clob field it is telling that there is a general error. CAN ANY ONE TRY TO TELL HOW TO RETRIVE
i am putting the code hear
The insertion code is<HTML><HEAD>
</HEAD>
<BODY bgcolor="pink">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.File" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.io.*" %>
<CENTER>
<%
Properties props = new Properties();
props.put("user", "intelligent");
props.put("password", "intercom");
props.put("SetBigStringTryClob", "true");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:intelligent",props);
try
{
PreparedStatement ps = con.prepareStatement("INSERT INTO persons1 values(?,?)");
String fn="D:\\test\\er.wma";
BufferedReader br = new BufferedReader(new FileReader(fn));
String nextLine = "";
StringBuffer sb = new StringBuffer();
while ((nextLine = br.readLine()) != null)
{ sb.append(nextLine); }
// Convert the content into to a string
String clobData = sb.toString(); // Return the data.
ps.setString(1,"krishna");
ps.setString(2,clobData);
ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</center>
</body>
</html>
The retrieving code is
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="pink">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.File" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.io.*" %>
<CENTER>
<%
out.println("gdjhg");
Properties props1 = new Properties();
props1.put("user", "intelligent");
props1.put("password", "intercom");
props1.put("SetBigStringTryClob", "true");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:intelligent",props1);
out.println("gdjhg");
try
{
String sqlcall="select name,pictur from persons1";
PreparedStatement ps1 = con.prepareStatement(sqlcall);
out.println("thanks");
ResultSet rs1 = ps1.executeQuery();
out.println("gdjhg");
String n1=null;
String clobVal = null;
while (rs1.next()) {
String n1 = rs1.getString(1);
String c1= rs1.getString(2);
}
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</center>
</body>
</html>
when i am trying to retrieve the clob field it is telling that there is a general error. CAN ANY ONE TRY TO TELL HOW TO RETRIVE
i am putting the code hear
The insertion code is<HTML><HEAD>
</HEAD>
<BODY bgcolor="pink">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.File" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.io.*" %>
<CENTER>
<%
Properties props = new Properties();
props.put("user", "intelligent");
props.put("password", "intercom");
props.put("SetBigStringTryClob", "true");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:intelligent",props);
try
{
PreparedStatement ps = con.prepareStatement("INSERT INTO persons1 values(?,?)");
String fn="D:\\test\\er.wma";
BufferedReader br = new BufferedReader(new FileReader(fn));
String nextLine = "";
StringBuffer sb = new StringBuffer();
while ((nextLine = br.readLine()) != null)
{ sb.append(nextLine); }
// Convert the content into to a string
String clobData = sb.toString(); // Return the data.
ps.setString(1,"krishna");
ps.setString(2,clobData);
ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</center>
</body>
</html>
The retrieving code is
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="pink">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.File" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.io.*" %>
<CENTER>
<%
out.println("gdjhg");
Properties props1 = new Properties();
props1.put("user", "intelligent");
props1.put("password", "intercom");
props1.put("SetBigStringTryClob", "true");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:intelligent",props1);
out.println("gdjhg");
try
{
String sqlcall="select name,pictur from persons1";
PreparedStatement ps1 = con.prepareStatement(sqlcall);
out.println("thanks");
ResultSet rs1 = ps1.executeQuery();
out.println("gdjhg");
String n1=null;
String clobVal = null;
while (rs1.next()) {
String n1 = rs1.getString(1);
String c1= rs1.getString(2);
}
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</center>
</body>
</html>