i am trying to connect to teradata and execute a statement and reading the data using stringbuilder. I want the get this as output when i define the outparameter as string the output is getting truncated as it is greater than 50K characters, i want this to be coverted as CLOB and give me the output as CLOB, could some one please help me how i can achieve this.
here is the code i am using ..
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.util.*;
import java.sql.*;
public class getDDLinfo {
public static void getDDL (int [] status, String objectType, String objName, String [] ddl)
throws SQLException {
ddl[0] = "Unknown failure in XSP.";
status[0] = 1;
Connection conn = DriverManager.getConnection("jdbc:default:connection");
try {
String sql = "show " + objectType + " " + objName + ";";
PreparedStatement stmt = conn.prepareStatement(sql);
StringBuilder result = new StringBuilder();
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
result.append(rs.getString(1));
result.append("\n");
}
if (result.length() > 0) {
ddl[0] = result.toString();
}
rs.close();
stmt.close();
conn.close();
status[0] = 0;
} catch (SQLException e) {
status[0] = e.getErrorCode();
ddl[0] = e.getMessage();
}
}
public static String toHexString(byte[] ba)
{
StringBuilder str = new StringBuilder();
for(int i = 0; i < ba.length; i++)
str.append(String.format("%x ", ba[i]));
return str.toString();
}
}