Read from server and display in external frame

Hello everyone,
I am using Eclipse, My project consist of server and client connected through a socket. When I connect to the server, i am getting lots of data from the server and it takes a bit of time, so I was thinking while the user wait for the data, i will pop up a frame with a text area displaying the data that the client is recieving at the moment.
Basiclly, instead of just displaying the data recieved in the console (readline) i would like to display it in an external frame.
something like this:
JEditorPane textArea = new JEditorPane("text/html", "Getting All IDs");
JScrollPane scroller = new JScrollPane(textArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
     JScrollPane. HORIZONTAL_SCROLLBAR_AS_NEEDED);
JOptionPane optPane = new JOptionPane(scroller,
     JOptionPane.OK_OPTION);
JDialog d = optPane.createDialog(null, "Data Receiving:");
myClient.readMsg(data);
scroller.add(data, textArea);
Please help.
thx

Hello,
if you not receive HTML-pages or HTML-formatted text, i suggest to use JTextPane instead of JEditorPane, as formatting color and font seems to be a little bit easier to do.
Next, i recommend to define a litte interface, ..
public interface DataReceivedListener {
  void dataReceived(String line);
}.. which then is implemented by the class the JTextPane is embedded into:
public class MainFrame extends JFrame implements DataReceivedListener {
  private JTextPane textPane;
  private StyledDocument doc;
  private Style defaultStyle;
  public void dataReceived(String line) {
    if (!line.equals(DataServer.EOF)) {
      try {
        doc.insertString(doc.getLength(), line + "\n", defaultStyle);
      } catch (BadLocationException ble) { ble.printStackTrace(); }
}Within the constructor of that main class you instantiate the style used for the received data lines and then pass this main class itself to the constructor of your server class:
public MainFrame() {
  doc = textPane.getStyledDocument();
  defaultStyle = doc.getStyle("default");
  DataServer server = new DataServer(this);
}The server class stores the listener, and when the server receives lines they will be forwarded to the main frame class:
public class DataServer implements Runnable {
  DataReceivedListener listener;
  public DataServer(DataReceivedListener listener) {
    this.listener = listener;
  public void run() {
    while (null != (line = instream.readLine())) {
      listener.dataReceived(line);
}You can easily change the line foreground color in dataReceived(String) by deriving other styles from defaultStyle:
Style redForeground = doc.addStyle("red", defaultStyle);
StyleConstants.setForeground(redForeground, Color.RED);
Style blueForeground = doc.addStyle("blue", defaultStyle);
StyleConstants.setForeground(blueForeground, Color.BLUE);This way you can switch the foreground color by passing the appropriate style to the text inserting method (see above):
currentForeground = currentForeground == redForeground ? blueForeground : redForeground;
doc.insertString(doc.getLength(), line + "\n", currentForeground);I could post an complete example of that, but i try to be short and hope this posting will help...

Similar Messages

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

  • How to load and display the external flv video files in dynamicly and the how to control the flv fil

    How to load and display the external flv video files in dynamicly using AS 3.0
    and  How to control the flv file  add the play paus button and add seekbar.
    I have using to load the flv file following code
    var flvPlaceHolder1:MovieClip = new MovieClip();
    var vid1:Video = new Video(734, 408);
    flvPlaceHolder1.addChild(vid1);
    addChild(flvPlaceHolder1);
    flvPlaceHolder1.x = 1059;
    flvPlaceHolder1.y = 152;
    var nc1:NetConnection = new NetConnection();
    nc1.connect(null);
    var ns1:NetStream = new NetStream(nc1);
    vid1.attachNetStream(ns1);
    var listener1:Object = new Object();
    listener1.onMetaData = function(evt:Object):void {};
    ns1.client = listener1;
    ns1.play("GV-1600 TURNING.flv");
    ns1.addEventListener(NetStatusEvent.NET_STATUS, statusChanged1);
    function statusChanged1(ns1:NetStatusEvent):void
             trace(ns1.info.code);
            if (ns1.info.code == 'NetStream.Buffer.Empty')
                 trace('the video has ended');
                 removeChild(flvPlaceHolder1);
                 //trace('removeChild');
                gotoAndPlay(1786);
    then how to add the play,paus ,full screen button    and   seekbar,volumebar.

    I have to Create the flash presentation for our company product
    In this presentation the left  side the text animation are displayed then right side the our product video is displayed.
    In this presentation i need the following option :
    1, The first product video and animation is finished then the next product is played
    2, then the video displayed  (size width and height 400x300) , I click this video to increase the size(ex:1000x700)
    3, then the playing video i control  it play, stop, paus button and volume bar, seek bar.
    4, then this presentation is displayed on 42 inches LCD TV so this full presentation is run full screen.
    I have finished first two steps 1 and 2
    the following are the screen short and code:-
    code :-
    var count=0;
    var flvPlaceHolder2:MovieClip = new MovieClip();   
    var vid2:Video = new Video(734, 408);
    flvPlaceHolder2.addChild(vid2);
    addChild(flvPlaceHolder2);
    flvPlaceHolder2.x = 1059;
    flvPlaceHolder2.y = 152;
    var nc2:NetConnection = new NetConnection();
    nc2.connect(null);
    var ns2:NetStream = new NetStream(nc2);
    vid2.attachNetStream(ns2);
    var listener2:Object = new Object();
    listener2.onMetaData = function(evt:Object):void {};
    ns2.client = listener2;
    ns2.play("GS-4000.flv");
    this.addEventListener(Event.ENTER_FRAME, BtnFadeIn2);
    function BtnFadeIn2(event:Event):void
        if (this.currentFrame == 387)
            /*flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            trace('Screen size is changed');*/
            if(count==0)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            count++;
    ns2.addEventListener(NetStatusEvent.NET_STATUS, statusChanged2);
    function statusChanged2(ns2:NetStatusEvent):void
        trace(ns2.info.code);
        if (ns2.info.code == 'NetStream.Buffer.Empty')
                trace('the video has ended');
                 removeChild(flvPlaceHolder2);
                 //trace('removeChild');
                gotoAndPlay(433);
    flvPlaceHolder2.buttonMode=true;
    flvPlaceHolder2.addEventListener(MouseEvent.CLICK,home2);
    function home2(e:MouseEvent):void
        if(vid2.width==734 && vid2.height==408)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
        else
            flvPlaceHolder2.x = 1059;
            flvPlaceHolder2.y = 152;
            vid2.width=734;
            vid2.height=408;

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Can't reinstall osx lion from internet, and display a message"cannot find installation information ,please contact applecare, what should i do?

    hello
    I can't reinstall osx lion from internet, and display a message"cannot find installation information ,please contact applecare, what should i do?
    thanks

    I'm no Lion expert, but I believe you can boot from the Recovery partition by pressing the Command and R keys on startup, then reinstall.

  • Call  RFC from ECC and display the values in  AET

    Hi ALL,
    I had an RFC in ECC ( Z_CRM_SPEC_DATA) this should be called into my AET Fields in getter method.
    In getter method of tat AET field what code should i write?
    Plz help me on this.

    HI,
    1) Call the  RFC(Z_CRM_SPEC_DATA) from ECC and display the values as mentioned in below AET fields.
    AET FIELDS :    zzfld00000M    zzfld00000N
    Description  :    Budget Quan    Forecast Quan
    values         :    (--5.0)(6.0--
    2) (Fetch Budget and Forecast data from ECC ),you would need to pass Material Number(MATNR) as well as Ship to party info to fetch the budget and forecast data as one material may be assigned to 2 or more SH with specific budget and forecast data for each.
    Edited by: venkatabharathv on May 23, 2011 2:44 PM
    Edited by: venkatabharathv on May 23, 2011 2:49 PM

  • How to retrieve xml file from BLOB and display on browser with css/xslt

    Hi All,
    I am new to xml. I am storing my xml file into BLOB in database. Now in my jsp page I want to retrieve this xml file from BLOB and display in HTML/CSS/XSLT form...
    Pl. guide me.. any docs..?? Logic...??
    Thanks in Advance.
    Sandeep Oza

    Hello Sandeep!
    I'm not familiar with jsp but logic should be as follows:
    -in jsp page instantiate XML parser
    -load specified BLOB into parser
    Now you may traverse the XML tree or you might load XSL file and use transform method to transform XML according to XSL file.
    I have an example where I'm selecting XML straight from relational database and then transform it using XSL into appropriate HTML output, but it's written in PSP.
    You can try http://www.w3schools.com/default.asp for basics on XML, CSS, XSL. It's easy to follow with good examples.
    Regards!
    miki

  • Redundant folders created in root of C drive of server and Client . I want to stop the same and want to automatically delete them from server and client .

    Redundant folders created in root of C drive of server and Client . I want to stop the same and want to automatically delete them from server and client .
    Please let me know the solution to delete them not manually . It should not create automatically .Is there a way we can change the path of creation.
    Is there a way that once the folfer is create should be automatically deleted once the task is done.
    Redundant folders are created in the root of my C drive all the time,
    folder names look like:
    09b0508d0bd2dbd70523
    56f51b81c1462bb378009ee4d5ed03
    02afe4378371907aca40ab

    This is a duplicate of
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/ae99c2d0-8dea-4c5e-8a79-17e08e9e5de4/sccm-2012-issue-folders-with-long-guid-are-created-in-c-drive?forum=winservergen#ae99c2d0-8dea-4c5e-8a79-17e08e9e5de4
    Jason | http://blog.configmgrftw.com

  • No more data to read from socket" and OALL8 is in an inconsistent state

    HI All
    user getting various errors – such as “No more data to read from socket” and “OALL8 is in an inconsistent state”.
    database is on windows 2k8-64 bit
    database is 11.2.0.1.0
    is this problem with JDBC drivers on client side
    thanx

    You will usually get this error when the connection get drop before completing the query/transaction.
    Check the alert log file for core dump as well as the trace file associated to the core dump.
    Also check if you are using the right driver version (ojdbc?)
    Regards
    Michel.
    www.odbTools.com

  • Is there any way to know data is read from tape and written to disk

    is there any way to know data is read from tape and written to disk

    784786 wrote:
    Just asked because I am doing restoration, I see files read from tape and then restored, but can't find them physically there.
    Is there any way I can find it.What kind of restoration? What kind of files?
    The usual "no information" question is of the form "My car won't start. Tell me how to fix it"
    Yours is a bit different - "I tried to fix my car. Tell me how to know it's fixed".

  • Read integer values from spreadsheet and display the values in a table

    Hi all,
    I have integer values to read from a spreadsheet and display them in a table. I am using 'Read from spreadsheet file' in 'integer' mode. I would like to display these values in a table. The problem is that the table takes only 2d-array of string as input but not integer.  
    It works fine if I change the mode of 'Read from spreadsheet file' from 'integer' to 'string' but I want to read integers and have to use the integer values for further calculations. Please give any suggestions on displaying integers to a table.
    Thank you. 
    Solved!
    Go to Solution.

    No don't take element by element just convert as a whole. See the attached example
    Good luck
    The best solution is the one you find it by yourself

  • Read byteArray(binary) from backend and display as pdf in flex titleWindow

    i have requirement where the pdf come as byteArray from backend, which i need to read from flex app and diaplay as pdf in the flex titleWindow or any flex popup.
    any ideas on this....,

    Hello Sandra,
    Thanks for your reply, but eventhen it fails to load the pdf. Is ADS required to be installed for this?
    Can I just pass the pdf_fsize imported from  CONVERT_OTF which is of type i.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          FORMAT                = 'PDF'
        IMPORTING
          BIN_FILESIZE          = PDF_FSIZE    
    bin_file              = pdfxstring
        TABLES
          OTF                   = L_JOB_OUTPUT_INFO-OTFDATA
          LINES                 = LT_PDF
        EXCEPTIONS
          ERR_MAX_LINEWIDTH     = 1
          ERR_FORMAT            = 2
          ERR_CONV_NOT_POSSIBLE = 3
          OTHERS                = 4.
      CALL METHOD G_HTML_CONTROL->LOAD_DATA(
         EXPORTING
           TYPE         = 'application' "'text' " 'application'
           SUBTYPE      = 'pdf' "'html'  "'pdf'
           size           = PDF_FSIZE
         IMPORTING
           ASSIGNED_URL         = lv_URL
         CHANGING
           DATA_TABLE           =  LT_DATA "i_html "LT_DATA
         EXCEPTIONS
           DP_INVALID_PARAMETER = 1
           DP_ERROR_GENERAL     = 2
           CNTL_ERROR           = 3
           OTHERS               = 4 ).
    Thanks,
    Jaya.

  • Mail not getting all messages from server and other strange behavior

    Hello All,
    Mail has been doing some odd things for me of late (at least the last week) and I'm lost for a solution to my problem. As far as I can tell, perhaps my Prefs. have become corrupted, or at least something in relation to Mail has become corrupted. Perhaps someone has a solution to this issue before I have to back it all up and NUKE the whole **** app to get back up and running properly.
    The main issue I appear to be having is that Mail is not getting all of my Mail messages from my server. I can log into my web-mail interface provided by my domain host and can see there that there are many e-mails that don't appear to be coming down the pipe to the Mail.app client. I'm getting some e-mail's but not all....
    *Here are all the things that I've checked:*
    • The missing e-mails are not being picked up as Junk and are not in the Junk folder
    • I have done a search within Mail for the missing e-mail's and nothing turns up anywhere.
    • I have checked on the server end that I'm not maxing out my InBox or that there are any other service issues from my domain host provider.
    • I have been into Prefs and checked my account settings - most (see below) of which appear to be as normal and are fine.
    *Here are the weird things that I've noticed:*
    • When I went into the Prefs. for the account in question, I noticed that my login had changed. For example - it usually it is "[email protected]", however it had seemed to have changed to just "johndoe" - I know this wasn't me as my domain host will not allow me to access any mail unless the login is the full mail address.
    • In RULES, every rule I double click to check on seems mostly fine, apart from the fact that every "Account is:" the pull down menu just appears as blank. Usually it says "Account is: ([email protected])"
    It's there last 2 items that make me think something is corrupted - so I guess my question is, what pref or file has corrupted and how can I fix it without having to give Mail.app a digital enema?
    Any assistance would be most helpful - missing some but not all your incoming e-mail messages is quite annoying, as you can guess...!
    Thanks,
    Boz

    Hello Boz.
    This appears to be a rules issue. Mail is almost certainly downloading those messages, but they’re probably being processed by your rules in an unexpected way — given the information you’ve provided, maybe because there is something wrong with the file where the account settings are stored.
    Do you have any Mail plug-ins? In the Finder, go to each of the following folders (if they exist). What do you see there?
    /Library/InputManagers/
    /Library/Mail/Bundles/
    ~/Library/InputManagers/
    ~/Library/Mail/Bundles/
    To make accurately reporting this information easier, you may open /Applications/Utilities/Terminal, type the following command (you can just copy it here and paste it in Terminal), and press <Return>. You can then copy the output of that command from Terminal and paste it in your reply to this post:
    ls -1 /Library/InputManagers /Library/Mail/Bundles ~/Library/InputManagers ~/Library/Mail/Bundles
    <hr>
    Verify/repair the startup disk (not just permissions), as described here:
    The Repair functions of Disk Utility: what's it all about?
    After having fixed all the filesystem issues, if any, and ensuring that there’s enough space available on the startup disk (a few GB, plus the space needed to make a backup copy of the Mail folder), try this:
    1. Write down your Mail > Preferences > Accounts settings or take screen shots of them.
    2. If you have a .Mac account and .Mac synchronization of Mail data is enabled either in Mail > Preferences > General or in System Preferences > .Mac, disable it before proceeding.
    3. Quit Mail.
    4. Make a backup copy of the ~/Library/Mail folder, just in case something goes wrong while trying to solve the problem. You can do this in the Finder by dragging the Mail folder to the Desktop while holding the Option (Alt) key down, for example. This is where all your mail is locally stored.
    5. In the Finder, go to ~/Library/Preferences/. Locate com.apple.mail.plist and move it to the Desktop (to be deleted if this solves the problem). If you have a backup of your data that includes a working copy of this file, you may try restoring it from the backup to avoid steps 6-8.
    6. Open Mail. You’ll have to set up your non-.Mac accounts from scratch all over again. If given the option to import existing mailboxes or something like that, don’t. Just enter the account information and Mail will automagically rediscover the data in ~/Library/Mail/ when done.
    7. You’ll have to re-configure some of your Mail > Preferences settings. For spam-related security reasons, the first thing you should do is go to Preferences > Viewing and disable Display remote images in HTML messages if it’s enabled.
    8. As a side effect of re-creating com.apple.mail.plist, Mail might rename Outbox (which is where messages waiting to be sent are stored) to Delivered. The name of that mailbox is actually a misnomer, as it would contain messages (if any) that couldn’t be delivered for some reason. You can delete that mailbox if you wish.
    9. If the problem is fixed now and .Mac synchronization of Mail data was enabled at the beginning, enable it again, go to System Preferences > .Mac > Advanced, click Reset Sync Data, and choose the appropriate options to reset the Mail data stored on the .Mac server with the data locally stored on the computer, i.e. sync data must flow from the computer to the .Mac server.
    <hr>
    Note: For those not familiarized with the ~/ notation, it refers to the user’s home folder. You can easily locate any of the folders referred to in this post by copying the folder path here, doing Go > Go to Folder in the Finder, and pasting the folder path there.

  • How to  Get input from  User and Display it's Value

    Hi ,
    I need to get 2 inputs from user and to display it's Mutilple Value.
    The Below Code is working fine to get 2 Input's from user,but it display a Junk value as a Result .How to
    overcome this Problem. I need to display it's Mutilple(a*b) value of "a " and " b".
    import java.io.*;
    class Mul{
    static int a=0;
    static int b=0;
    static int Count=0;
    public static void main(String args[])throws IOException{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    do{
    a=(char)br.read();
    Count++;
    b=(char)br.read();
    if(Count==2)
    System.out.println("The Multiplied Value is "+a*b);
    }while(Count<2);
    }

    Changed to Integer but still the problem persists.
    import java.io.*;
    class Mul{
    static int a=0;
    static int b=0;
    static int Count=0;
    public static void main(String args[])throws IOException{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    do{
    a=(int)br.read();
    Count++;
    b=(int)br.read();
    if(Count==2)
    System.out.println("The Multiplied Value is "+a*b);
    }while(Count<2);
    }

  • How to read from BLOB and Write to a file in user readable format.

    Hi,
         I am trying to read from a BLOB column and write the content to a file in user readable format. So far I was able to read the Blob column using dbms_lob, but not able to write to a file. Kindly let me know the method to do this.

    Hi, with this Java Code from Oracle Technet it's a easy thing:
    // classpath= /ORACLE/u01/app/oracle/product/10.2.0.3/jdbc/lib/ojdbc14.jar
    // Java SQL classes
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    // Oracle JDBC driver class
    import oracle.jdbc.OracleDriver;
    // Java IO classes
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    //Java Util classes
    import java.util.Properties;
    * This class demonstrates the Oracle JDBC 10g enhanced features for inserting
    * and retrieving CLOB data from the database. Using the new features, large
    * data of more than 32765 bytes can be inserted into the database using the
    * existing PreparedStatement.setString() and PreparedStatement.getString()
    * methods.
    public class ClobMan {
    /* Database Connection object */
    private Connection conn = null;
    /* Variables to hold database details */
    private String url = null;
    private String user = null;
    private String password = null;
    // Create a property object to hold the username, password and
    // the new property SetBigStringTryClob.
    private Properties props = new Properties();
    /* String to hold file name */
    private String fileName = null;
    * Default Constructor to instantiate and get a handle to class methods
    * and variables.
    public ClobMan(String fileName) {
    this.fileName = fileName;
    * Main runnable class.
    public static void main(String[] args) throws SQLException {
    // Instantiate the main class.
    ClobMan clobMan = new ClobMan(args[0]);
    // Load the Oracle JDBC driver class.
    DriverManager.registerDriver(new OracleDriver());
    // Load the database details into the variables.
    String dbUrl = "jdbc:oracle:thin:@pmol:1550:dbpmol";
    clobMan.url = dbUrl;
    clobMan.user = "gh10";
    clobMan.password = "secret";
    // Populate the property object to hold the username, password and
    // the new property 'SetBigStringTryClob' which is set to true. Setting
    // this property allows inserting of large data using the existing
    // setString() method, to a CLOB column in the database.
    clobMan.props.put("user", clobMan.user );
    clobMan.props.put("password", clobMan.password);
    clobMan.props.put("SetBigStringTryClob", "true");
    // Check if the table 'CLOB_TAB' is present in the database.
    //clobMan.checkTables();
    // Call the methods to insert and select CLOB from the database.
    //clobMan.insertClob();
    clobMan.selectClob();
    * This method will insert the data into a CLOB column in the database.
    * Oracle JDBC 10g has enhanced the existing PreparedStatement.setString()
    * method for setting the data more than 32765 bytes. So, using setString(),
    * it is now easy to insert CLOB data into the database directly.
    private void insertClob() throws SQLException {
    // Create a PreparedStatement object.
    PreparedStatement pstmt = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query to insert data into the CLOB column in the database.
    String sql = "INSERT INTO clob_tab VALUES(?)";
    // Read a big file(larger than 32765 bytes)
    String str = this.readFile();
    // Create the OraclePreparedStatement object
    pstmt = conn.prepareStatement(sql);
    // Use the same setString() method which is enhanced to insert
    // the CLOB data. The string data is automatically transformed into a
    // clob and inserted into the database column. Make sure that the
    // Connection property - 'SetBigStringTryClob' is set to true for
    // the insert to happen.
    pstmt.setString(1,str);
    // Execute the PreparedStatement
    pstmt.executeUpdate();
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and inserting into " +
    "the database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and inserting into the" +
    " database table: " + ex.toString());
    } finally {
    // Close the Statement and the connection objects.
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * This method reads the CLOB data from the database by using getString()
    * method.
    private void selectClob() throws SQLException {
    // Create a PreparedStatement object
    PreparedStatement pstmt = null;
    // Create a ResultSet to hold the records retrieved.
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query statement to retrieve records having CLOB data from
    // the database.
    String sqlCall = "SELECT rownum, name, sourcetext FROM t_source";
    pstmt= conn.prepareStatement(sqlCall);
    // Execute the PrepareStatement
    rset = pstmt.executeQuery();
    String rownum = null;
    String o_name =null;
    String clobVal = null;
    // Get the CLOB value from the resultset
    //java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter("pr_all.sql"));
    while (rset.next()) {
    rownum = rset.getString(1);
         o_name = rset.getString(2);
         clobVal = rset.getString(3);
    System.out.println(" length: "+clobVal.length()+" "+o_name+" "+rownum);
         java.io.BufferedWriter out =
         new java.io.BufferedWriter(new java.io.FileWriter(o_name+".prc"));
         out.write(clobVal);
         out.newLine();
         out.write("/");
         out.newLine();
         out.newLine();
    out.flush();
    out.close();
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and querying the " +
    "database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and querying the " +
    "database table: " + ex.toString());
    } finally {
    // Close the resultset, statement and the connection objects.
    if (rset !=null) rset.close();
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * Method to check if the table ('CLOB_TAB') exists in the database; if not
    * then it is created.
    * Table Name: CLOB_TAB
    * Column Name Type
    * col_col CLOB
    private void checkTables() {
    Statement stmt = null;
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create Statement object
    stmt = conn.createStatement();
    // Check if the table is present
    rset = stmt.executeQuery(" SELECT table_name FROM user_tables "+
    " WHERE table_name = 'CLOB_TAB' ");
    // If the table is not present, then create the table.
    if (!rset.next()) {
    // Table does not exist, create it
    stmt.executeUpdate(" CREATE TABLE clob_tab(clob_col CLOB)");
    } catch (SQLException sqlEx) {
    System.out.println("Could not create table clob_tab : "
    +sqlEx.toString());
    } finally {
    try {
    if( rset != null ) rset.close();
    if( stmt != null ) stmt.close();
    if (conn!=null) conn.close();
    } catch(SQLException ex) {
    System.out.println("Could not close objects in checkTables method : "
    +ex.toString());
    * This method reads the specified text file and, returns the content
    * as a string.
    private String readFile()
    throws FileNotFoundException, IOException{
    // Read the file whose content has to be passed as String
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    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.
    return clobData;
    }

Maybe you are looking for

  • My iphone 4s goes to a black screen when in use of any apps. after the update to ios6 any ideas for a fix?

    Since i updated to ios 6 my iphone goes to a black screen when it is in use. I could be texting and 5-10 sec later it goes to a black screen and than to the home page. Its also will be when playing games and so on. Can you please help me with this? I

  • Problem with cd/dvd drive on my Satellite 1900-303

    Hi Every body I bought a Satellite 1900-303 in 2003. Recently, it's cd/Dvd drive stopped to work properly. whenever I put a Cd in the driver it assumes that the CD is a audio cd. if the CD is completly Audio cd or partly contained audio files it open

  • IPod Touch 2 gen (16 GB) will not update

    My iPod Touch will not update to version 3. iTunes stops in the middle of the process of downloading the update file, and tells me the network connection has been reset. I have also tried restoring it, but the same thing happened and now the iPod wil

  • I want to use the MXCTRLLib functions from VB. Are there any examples?

    I have tried '* place a reference to the max library first dim aa as mxConfiguration set aa = new mxconfiguration aa.invokeMAX ' starts a MAX session 'aa.invokecreatenewwizard(0,"test") = "help" 'starts the wizard for a new channel The above code sta

  • 5508 Guest Anchor 7.4MR2

    We are upgrading all Foreign 5508 WLC's to 7.4MR2.  Out Guest Anchor is currently on 7.0.235.  Any reason not to upgrade the Guest Anchor to 7.4MR2?  Has anyone encountered any issues doing this?  We are not having any issues on 7.0, and I just did n