public ArrayList find(int theBegin, int theEnd) throws SQLException { ArrayList list = new ArrayList(); String sql = "select NODE_LINK_ID, NAME, DESCRIPTION, LINK_TYPE, TEMPLATE_ID, CURRENT_NODE_ID, NEXT_NODE_ID, EXECUTOR_RELATION, EXECUTORS_METHOD, NUMBER_OR_PERCENT, PASS_VALUE, EXPRESSION, DEFAULT_PATH, ACTION_NAME from WF_LINK"; PreparedStatement st = null; ResultSet rs = null; Connection conn = null; try { conn = ConnectionFactory.getConnection(); st = conn.prepareStatement(sql); if (theEnd > 0) st.setFetchSize(theEnd); rs = st.executeQuery(); if (theBegin > 1) rs.absolute(theBegin - 1); while (rs.next()) { list.add(parseResultSet(rs)); if (rs.getRow() == theEnd) break; } } catch (SQLException e) { e.printStackTrace(); throw new SQLException(e.getMessage()); } finally { DBHelper.closeConnection(conn, st, rs); } return list; }
public void updateDb(Connection con) { try (Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM contact where firstname = \"Michael\"")) { resultSet.absolute(1); // 1 zmienic na dokładny wiersz w ktorym jest michael - metadata? resultSet.updateString("phoneNumber", "+009392032302"); resultSet.updateRow(); System.out.println(" After the update"); System.out.println("ID \tfName \tsurname \temail \t\tphoneNo"); resultSet.beforeFirst(); while (resultSet.next()) { System.out.println( resultSet.getInt("id") + "\t" + resultSet.getString("name") + "t\"" + resultSet.getString("surname") + "t\"" + resultSet.getString("email") + "t\"" + resultSet.getString("phoneNumber")); } } catch (SQLException e) { e.printStackTrace(); } }
public ArrayList getFollowedLinkList(int theBegin, int theEnd, int templateId, int currentNodeId) throws SQLException { ArrayList list = new ArrayList(); String sql = "select * from wf_link where template_id = ? and current_node_id = ?"; PreparedStatement st = null; ResultSet rs = null; Connection conn = null; try { conn = ConnectionFactory.getConnection(); st = conn.prepareStatement(sql); if (theEnd > 0) st.setFetchSize(theEnd); st.setInt(1, templateId); st.setInt(2, currentNodeId); rs = st.executeQuery(); if (theBegin > 1) rs.absolute(theBegin - 1); while (rs.next()) { list.add(parseResultSet(rs)); if (rs.getRow() == theEnd) break; } } catch (SQLException e) { e.printStackTrace(); throw new SQLException(e.getMessage()); } finally { DBHelper.closeConnection(conn, st, rs); } return list; }
/* * Execute query against a list of sensors * * */ public static String executeQuery( String envelope, String query, String matchingSensors, String format) throws ParseException { // String matchingSensors = getListOfSensorsAsString(envelope); String reformattedQuery = reformatQuery(query, matchingSensors); StringBuilder sb = new StringBuilder(); Connection connection = null; try { connection = Main.getDefaultStorage().getConnection(); Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet results = statement.executeQuery(reformattedQuery); ResultSetMetaData metaData; // Additional information about the results int numCols, numRows; // How many rows and columns in the table metaData = results.getMetaData(); // Get metadata on them numCols = metaData.getColumnCount(); // How many columns? results.last(); // Move to last row numRows = results.getRow(); // How many rows? String s; // System.out.println("* Executing query *\n" + reformattedQuery + "\n***"); // headers // sb.append("# Query: " + query + NEWLINE); sb.append("# Query: " + reformattedQuery.replaceAll("\n", "\n# ") + NEWLINE); sb.append("# "); // System.out.println("ncols: " + numCols); // System.out.println("nrows: " + numRows); for (int col = 0; col < numCols; col++) { sb.append(metaData.getColumnLabel(col + 1)); if (col < numCols - 1) sb.append(SEPARATOR); } sb.append(NEWLINE); for (int row = 0; row < numRows; row++) { results.absolute(row + 1); // Go to the specified row for (int col = 0; col < numCols; col++) { Object o = results.getObject(col + 1); // Get value of the column // logger.warn(row + " , "+col+" : "+ o.toString()); if (o == null) s = "null"; else s = o.toString(); if (col < numCols - 1) sb.append(s).append(SEPARATOR); else sb.append(s); } sb.append(NEWLINE); } } catch (SQLException e) { sb.append("ERROR in execution of query: " + e.getMessage()); } finally { Main.getDefaultStorage().close(connection); } return sb.toString(); }
protected ResultSet send(String request) { ResultSet result; try { Statement state = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); result = state.executeQuery(request); result.absolute(1); } catch (SQLException e) { if (e.getErrorCode() != 0) System.err.println("Unable set the connection to the database!/n"); result = null; } return result; }
private int getRowCount(ResultSet rs) { int count = 0; try { rs.absolute(-1); count = rs.getRow(); rs.beforeFirst(); } catch (SQLException e) { printSQLException(e); } return count; }
public static void ProcessCustomerPayment(Connection conn) { // This function updates is_paid so billing staff can keep track of the payments customers have // made int c_id = BooksAThousand.getIntFromShell("Enter customer ID: "); try { Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = statement.executeQuery( "select customer_id, isbn, quantity, price, customer_order_date, is_paid" + " from customer_order where customer_id=" + c_id + " and is_paid='N'"); if (rs.next()) { System.out.println("Outstanding payments:"); System.out.printf( "Order %-10s %-5s %-5s %-10s %-10s\n", "ISBN", "Quant", "Price", "Total", "Date"); Date date; int i = 0; SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm"); do { i++; date = rs.getDate(5); System.out.printf( "%-5s: %-10s %-5d %-5d %-10d %-10s \n", i, rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getInt(3) * rs.getInt(4), sdf.format(date)); } while (rs.next()); int order = BooksAThousand.getIntFromShell("Which order to mark as paid: "); rs.absolute(i); rs.updateString(6, "Y"); rs.updateRow(); System.out.println("Update successful."); } else { System.out.println("This user has no unpaid orders"); } } catch (Throwable e) { e.printStackTrace(); } }
@Override public String getUniqueIDListingOfMessage(int messageNumber) { String uidl = ""; String query = "SELECT vchUIDL FROM m_Mail WHERE iMaildropID=" + seissionUserID + ";"; try (Statement statement = conn.createStatement()) { ResultSet rs = statement.executeQuery(query); rs.absolute(messageNumber); uidl = rs.getString("vchUIDL"); } catch (SQLException e) { printSQLException(e); } return messageNumber + " " + uidl; }
@Override public int getSizeOfMessageInOctets(int messageNumber) { int sizeOfMessageInOctets = 0; String query = "SELECT txMailContent FROM m_Mail WHERE iMaildropID=" + seissionUserID + ";"; try (Statement statement = conn.createStatement()) { ResultSet rs = statement.executeQuery(query); rs.absolute(messageNumber); sizeOfMessageInOctets = getNumberOfOctetsInString(rs.getString("txMailContent")); } catch (SQLException e) { printSQLException(e); } return sizeOfMessageInOctets; }
@Override public String getMessageBody(int messageNumber) { String messageBody = ""; String query = "SELECT txMailContent FROM m_Mail WHERE iMaildropID=" + seissionUserID + ";"; try (Statement statement = conn.createStatement()) { ResultSet rs = statement.executeQuery(query); rs.absolute(messageNumber); messageBody = rs.getString("txMailContent"); } catch (SQLException e) { printSQLException(e); } return messageBody; }
@Override public int getNumberOfLinesInMessageBody(int messageNumber) { int numberOfLines = 0; String query = "SELECT txMailContent FROM m_Mail WHERE iMaildropID=" + seissionUserID + ";"; try (Statement statement = conn.createStatement()) { ResultSet rs = statement.executeQuery(query); rs.absolute(messageNumber); String messageBody = rs.getString("txMailContent"); numberOfLines = messageBody.split("\\n").length; } catch (SQLException e) { printSQLException(e); } return numberOfLines; }
// 51.5 public SmTbProductBean[] loadByWhere(String where, int[] fieldList, int startRow, int numRows) throws SQLException { String sql = null; if (fieldList == null) sql = "select " + ALL_FIELDS + " from sm_tb_product " + where; else { StringBuffer buff = new StringBuffer(128); buff.append("select "); for (int i = 0; i < fieldList.length; i++) { if (i != 0) buff.append(","); buff.append(FIELD_NAMES[fieldList[i]]); } buff.append(" from sm_tb_product "); buff.append(where); sql = buff.toString(); buff = null; } Connection c = null; Statement pStatement = null; ResultSet rs = null; java.util.ArrayList v = null; try { c = getConnection(); pStatement = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = pStatement.executeQuery(sql); v = new java.util.ArrayList(); int count = 0; if (rs.absolute(startRow) && numRows != 0) { do { if (fieldList == null) v.add(decodeRow(rs)); else v.add(decodeRow(rs, fieldList)); count++; } while ((count < numRows || numRows < 0) && rs.next()); } return (SmTbProductBean[]) v.toArray(new SmTbProductBean[0]); } finally { if (v != null) { v.clear(); } getManager().close(pStatement, rs); freeConnection(c); } }
// 41.5 public SmTbProductBean[] loadByPreparedStatement( PreparedStatement ps, int[] fieldList, int startRow, int numRows) throws SQLException { ResultSet rs = null; java.util.ArrayList v = null; try { rs = ps.executeQuery(); v = new java.util.ArrayList(); int count = 0; if (rs.absolute(startRow) && numRows != 0) { do { if (fieldList == null) v.add(decodeRow(rs)); else v.add(decodeRow(rs, fieldList)); count++; } while ((count < numRows || numRows < 0) && rs.next()); } return (SmTbProductBean[]) v.toArray(new SmTbProductBean[0]); } finally { if (v != null) { v.clear(); v = null; } getManager().close(rs); } }
@Override public void markMessageForDeletion(int messageNumber) { String mailIDQuery = "SELECT iMailID FROM m_Mail WHERE iMaildropID=" + seissionUserID + ";"; try (Statement statement = conn.createStatement()) { ResultSet rs = statement.executeQuery(mailIDQuery); rs.absolute(messageNumber); String deleteQuery = "DELETE FROM m_MAil WHERE iMaildropID=" + seissionUserID + " AND " + "iMAilID=" + rs.getInt("iMailID") + ";"; statement.executeUpdate(deleteQuery); } catch (SQLException e) { rollbackCommit(); printSQLException(e); } }
private boolean executeQuery() { boolean returnVaue = true; int beginRow = 0; boolean moveIF = true; String lineOne = ""; ResultSet rst = null; ResultSetMetaData rstMetaData = null; int columnCount = 0; String temp = ""; rowNum = 0; if (querySQL == "") { writeLog("??????????"); quickField = ""; quickValue = ""; quickRow = -1; return false; } quickRow = -1; try { if (isProcedure) { rst = cstmt.executeQuery(); } else { if (stmt == null) init2(); rst = stmt.executeQuery(querySQL); } } catch (Exception e) { writeLog( (new StringBuilder("??��???????")) .append(e.toString()) .append(",sql=") .append(querySQL) .toString()); try { if (isProcedure && cstmt != null) cstmt.close(); else if (stmt != null) stmt.close(); } catch (SQLException sqlexception) { } returnVaue = false; return returnVaue; } try { rst.last(); totalRowCount = rst.getRow(); rst.beforeFirst(); } catch (Exception ex) { totalRowCount = 0; writeLog((new StringBuilder("??��???????")).append(ex.toString()).toString()); return returnVaue; } pageCount = BigInteger.valueOf(totalRowCount).divide(BigInteger.valueOf(perPage)).intValue(); if (BigInteger.valueOf(totalRowCount).mod(BigInteger.valueOf(perPage)).intValue() > 0) pageCount++; if (pageCount == 0) nextPage = 0; else if (nextPage > pageCount) nextPage = 0; beginRow = nextPage * perPage; beginRow++; curPage = nextPage; if (pageCount <= 1) { ifNext = false; nextPage = 0; } else if (nextPage > pageCount) { ifNext = false; nextPage = 0; } else { ifNext = true; } if (nextPage < 0) nextPage = 0; if (quickField != null && quickField.compareTo("") != 0 && pageCount != 0 && quickValue != null && quickValue.compareTo("") != 0) try { int colIndex = 0; String quickFieldName = ""; String quickFieldType = ""; String quickFieldTmp[] = (String[]) null; boolean haveFound = false; int findRow = 0; quickFieldTmp = StringUtil.split(quickField, ","); if (quickFieldTmp == null) throw new Exception((new StringBuilder("??????��??")).append(quickField).toString()); quickFieldName = quickFieldTmp[0]; quickFieldType = quickFieldTmp[1]; colIndex = rst.findColumn(quickFieldName); rst.beforeFirst(); while (!haveFound && rst.next()) { String tmpValue = ""; if (rst.getObject(colIndex) != null) { tmpValue = rst.getObject(colIndex).toString(); if (quickFieldType.compareToIgnoreCase("date") == 0) { int indexPos = -1; tmpValue = StringUtil.mk_date(tmpValue, 2); indexPos = tmpValue.indexOf(quickValue); if (indexPos == -1) { haveFound = false; } else { haveFound = true; findRow = rst.getRow(); } } else if (quickFieldType.compareToIgnoreCase("long") == 0) { int indexPos = -1; indexPos = tmpValue.compareTo(quickValue); if (indexPos == 0) { haveFound = true; findRow = rst.getRow(); } else { haveFound = false; } } else if (quickFieldType.compareToIgnoreCase("char") == 0) { int indexPos = -1; indexPos = tmpValue.indexOf(quickValue); if (indexPos == -1) { haveFound = false; } else { haveFound = true; findRow = rst.getRow(); } } } } if (findRow > 0) { int pageTmp = 0; int modTmp = 0; pageTmp = BigInteger.valueOf(findRow).divide(BigInteger.valueOf(perPage)).intValue(); modTmp = BigInteger.valueOf(findRow).mod(BigInteger.valueOf(perPage)).intValue(); if (modTmp == 0) { nextPage = pageTmp - 1; quickRow = perPage; } else { nextPage = pageTmp; quickRow = modTmp; } beginRow = nextPage * perPage; beginRow++; curPage = nextPage; if (nextPage >= pageCount - 1) { ifNext = false; nextPage = 0; } else { ifNext = true; nextPage = nextPage + 1; } } } catch (Exception exx) { writeLog(exx.toString()); quickRow = -1; } quickField = ""; quickValue = ""; try { rstMetaData = rst.getMetaData(); } catch (Exception e) { writeLog((new StringBuilder("???????")).append(e.toString()).toString()); returnVaue = false; } try { columnCount = rstMetaData.getColumnCount(); } catch (Exception e) { writeLog((new StringBuilder("??��??")).append(e.toString()).toString()); returnVaue = false; } Object object = null; for (int i = 1; i <= columnCount; i++) try { fieldVector.add(rstMetaData.getColumnName(i)); } catch (Exception e) { writeLog( (new StringBuilder("Exception while getColumnName?G")).append(e.toString()).toString()); } try { if (pageCount > 0) { try { rst.absolute(beginRow); moveIF = true; } catch (Exception exx) { moveIF = false; } if (moveIF) { for (int i = 1; i <= columnCount; i++) { try { object = rst.getObject(i); if (object == null) temp = ""; else temp = object.toString(); } catch (Exception e) { temp = ""; } if (temp == null) temp = ""; lineOne = (new StringBuilder(String.valueOf(lineOne))).append(temp).toString(); valueVector.add(temp); } if (lineOne.equals("")) { valueVector = new ArrayList(); rowNum = 0; } else { rowNum = 1; } for (int i = 1; i < perPage; i++) if (rst.next()) { rowNum++; for (int k = 1; k <= columnCount; k++) { try { if (rst.getObject(k) == null) temp = ""; else temp = rst.getObject(k).toString(); } catch (Exception e) { temp = ""; } if (temp == null) temp = ""; valueVector.add(temp); } } } } } catch (Exception e) { writeLog((new StringBuilder("??????")).append(e.toString()).toString()); returnVaue = false; } try { rst.close(); } catch (Exception exception) { } try { if (stmt != null) stmt.close(); } catch (Exception exception1) { } if (!returnVaue) resetBean(); colCount = columnCount; close(); return returnVaue; }
public static void main(String args[]) { try { String url; if (args.length == 0) url = "jdbc:virtuoso://localhost:1111"; else url = args[0]; Class.forName("virtuoso.jdbc3.Driver"); System.out.println("--------------------- Test of scrollable cursor -------------------"); System.out.print("Establish connection at " + url); Connection connection = DriverManager.getConnection(url, "dba", "dba"); if (connection instanceof virtuoso.jdbc3.VirtuosoConnection) System.out.println(" PASSED"); else { System.out.println(" FAILED"); System.exit(-1); } System.out.print("Create a Statement class attached to this connection"); Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); if (stmt instanceof virtuoso.jdbc3.VirtuosoStatement) System.out.println(" PASSED"); else { System.out.println(" FAILED"); System.exit(-1); } try { stmt.executeUpdate("drop table EX..DEMO"); } catch (Exception e) { } System.out.print("Execute CREATE TABLE"); if (stmt.executeUpdate("create table EX..DEMO (ID integer,FILLER integer,primary key(ID))") == 0) System.out.println(" PASSED"); else { System.out.println(" FAILED"); System.exit(-1); } System.out.print("Create a PStatement class attached to this connection"); PreparedStatement pstmt = connection.prepareStatement("INSERT INTO EX..DEMO(ID,FILLER) VALUES (?,?)"); System.out.println(" PASSED"); System.out.print("Execute INSERT INTO"); for (int i = 0; i < 100; i++) { pstmt.setInt(1, i); pstmt.setInt(2, i); if (pstmt.executeUpdate() != 1) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); pstmt.close(); System.out.print("Execute SELECT"); stmt.setMaxRows(100); stmt.setFetchSize(10); stmt.execute("SELECT * from EX..DEMO"); System.out.println(" PASSED"); System.out.print("Get the result set"); ResultSet rs = stmt.getResultSet(); if (rs instanceof virtuoso.jdbc3.VirtuosoResultSet) { System.out.println(" PASSED"); } else { System.out.println(" FAILED"); System.exit(-1); } System.out.print("Execute the resultset.beforeFirst()"); rs.beforeFirst(); System.out.println(" PASSED"); System.out.print("Execute the resultset.next()"); for (int i = 0; i < 100; i++) { rs.next(); if (rs.getInt(2) != i) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); System.out.print("Execute the resultset.afterLast()"); rs.afterLast(); System.out.println(" PASSED"); System.out.print("Execute the resultset.previous()"); for (int i = 99; i >= 0; i--) { rs.previous(); if (rs.getInt(2) != i) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); System.out.print("Execute the resultset.first()"); rs.first(); System.out.println(" PASSED"); System.out.print("Execute the resultset.next()"); for (int i = 0; i < 100; i++) { if (rs.getInt(2) != i) { System.out.println(" FAILED"); System.exit(-1); } rs.next(); } System.out.println(" PASSED"); System.out.print("Execute the resultset.last()"); rs.last(); System.out.println(" PASSED"); System.out.print("Execute the resultset.previous()"); for (int i = 99; i >= 0; i--) { if (rs.getInt(2) != i) { System.out.println(" FAILED"); System.exit(-1); } rs.previous(); } System.out.println(" PASSED"); System.out.print("Execute the resultset.absolute(>0)"); for (int i = 0; i != 100; i++) { rs.absolute(i + 1); if (rs.getInt(2) != i) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); System.out.print("Execute the resultset.absolute(<0)"); for (int i = -1, j = 99; i != -101; i--, j--) { rs.absolute(i); if (rs.getInt(2) != j) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); System.out.print("Execute the resultset.absolute(50)"); rs.absolute(50); System.out.println(" PASSED"); System.out.print("Execute the resultset.relative(>0)"); for (int i = 50; i != 90; i++) { if (rs.getInt(2) != i - 1) { System.out.println(" FAILED"); System.exit(-1); } rs.relative(1); } System.out.println(" PASSED"); System.out.print("Execute the resultset.absolute(50)"); rs.absolute(50); System.out.println(" PASSED"); System.out.print("Execute the resultset.relative(<0)"); for (int i = 50; i != 10; i--) { if (rs.getInt(2) != i - 1) { System.out.println(" FAILED"); System.exit(-1); } rs.relative(-1); } System.out.println(" PASSED"); System.out.print("Execute the resultset.first()"); rs.first(); System.out.println(" PASSED"); System.out.print("Update rows in the table"); for (int i = 0; i != 2; i++) { rs.updateInt("FILLER", i * 2); rs.updateRow(); rs.refreshRow(); if (rs.getInt(2) != i * 2) { System.out.println(" FAILED"); System.exit(-1); } rs.next(); } System.out.println(" PASSED"); System.out.print("Execute DELETE"); pstmt = connection.prepareStatement("DELETE FROM EX..DEMO WHERE ID=?"); for (int i = 0; i < 100; i++) { pstmt.setInt(1, i); if (pstmt.executeUpdate() != 1) { System.out.println(" FAILED"); System.exit(-1); } } System.out.println(" PASSED"); pstmt.close(); stmt.close(); stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); System.out.print("Execute DROP TABLE"); if (stmt.executeUpdate("DROP TABLE EX..DEMO") == 0) System.out.println(" PASSED"); else { System.out.println(" FAILED"); System.exit(-1); } System.out.print("Close statement at " + url); stmt.close(); System.out.println(" PASSED"); System.out.print("Close connection at " + url); connection.close(); System.out.println(" PASSED"); System.out.println("-------------------------------------------------------------------"); System.exit(0); } catch (Exception e) { System.out.println(" FAILED"); e.printStackTrace(); System.exit(-1); } }
public void createGUI() { setLayout(new BorderLayout()); JPanel topPan = new JPanel(new BorderLayout()); // topPan.setBorder(BorderFactory.createRaisedSoftBevelBorder()); JPanel topCentPan = new JPanel(); JLabel titleLab = new JLabel(); titleLab.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15)); topCentPan.add(titleLab); JPanel topRightPan = new JPanel(); // Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); replyBut = new JButton(new ImageIcon("src\\images\\replyIcon.png")); replyBut.setBorder(BorderFactory.createEmptyBorder()); replyBut.addActionListener(this); replyBut.setCursor(new Cursor(Cursor.HAND_CURSOR)); replyBut.setToolTipText("Reply"); replyBut.setContentAreaFilled(false); replyBut.setRolloverEnabled(true); forwardBut = new JButton(new ImageIcon("src\\images\\forwardIcon.png")); forwardBut.setBorder(BorderFactory.createEmptyBorder()); forwardBut.addActionListener(this); forwardBut.setCursor(new Cursor(Cursor.HAND_CURSOR)); forwardBut.setToolTipText("Forward"); forwardBut.setContentAreaFilled(false); forwardBut.setRolloverEnabled(true); topRightPan.add(replyBut); topRightPan.add(forwardBut); topPan.add(topCentPan, "Center"); topPan.add(topRightPan, "East"); JPanel centPan = new JPanel(new BorderLayout()); JPanel centTopPan = new JPanel(new BorderLayout()); JPanel centTopLeftPan = new JPanel(); JLabel fromLab = new JLabel(); fromLab.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); JTextArea contentTA = new JTextArea(); // JEditorPane contentTA = new JEditorPane(JEditorPane.W3C_LENGTH_UNITS,""); contentTA.setLineWrap(true); contentTA.setEditable(false); centTopLeftPan.add(fromLab); JPanel centTopRightPan = new JPanel(); JLabel dateLab = new JLabel(); dateLab.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); centTopRightPan.add(dateLab); centTopPan.add(centTopLeftPan, "West"); centTopPan.add(centTopRightPan, "East"); centPan.add(centTopPan, "North"); centPan.add(new JScrollPane(contentTA), "Center"); add(topPan, "North"); add(centPan, "Center"); try { workingSet.absolute(pointer + 1); msgID = Home.bodyPan.msgID[pointer]; titleLab.setText(workingSet.getString("subject")); fromLab.setText("From: " + workingSet.getString("mail_addresses")); dateLab.setText(workingSet.getString("sent_date")); contentTA.setText(workingSet.getString("content")); } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(this, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); } Home.bodyPan.remove(Home.bodyPan.contentPan); Home.bodyPan.contentPan = new JScrollPane(this); Home.bodyPan.add(Home.bodyPan.contentPan); Home.home.homeFrame.setVisible(true); }