Profile cover photo
Profile photo
Brandon Fischer
20 followers
20 followers
About
Brandon's interests
View all
Brandon's posts

Post has attachment

Post has attachment

Post has attachment

Post has attachment
Check out this video on YouTube:

 Does anyone have a moment to answer some questions about group policies and pushing .MSI files out for adobe reader? 

Post has attachment

Can anyone help me figure how to get this code to display correctly in a JTextArea? I'm using JDBC, we are able to get the code to send over the string buffer to the main class but the format will not display correctly. The first column will display straight as well as the second but after that the format is all sloppy. The strange thing is that we checked the code output into the command line output area and it will format it correctly when you display it in that area but not in the text area. If anyone can help that would be amazing! 

package pkgfinal;
import java.sql.*;

public class connectURL {
    // Declare the JDBC objects.
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String URLQuery;
private ResultSetMetaData rsmd;
private StringBuffer sbf;

 public connectURL(String queryString) throws Exception{
              sbf = new StringBuffer();
            //  sbf.delete(0, sbf.length());
                // URLQuery = query;
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=Final;integratedSecurity=true;";

       
        // Establish the connection.
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = DriverManager.getConnection(connectionUrl);
            String t =queryString;
            // Create and execute an SQL statement that returns some data.
            stmt = con.createStatement();
                       
            rs = stmt.executeQuery(t);
                        rsmd = rs.getMetaData();
       
            int columnCount = rsmd.getColumnCount ();
            String[] columnLabels = new String[columnCount];
            int[] columnWidths = new int[columnCount];
            for (int i = 1; i <= columnCount; ++i) { 
                columnLabels[i-1] = rsmd.getColumnLabel (i);
                columnWidths[i-1] = Math.max (columnLabels[i-1].length(),
                                              rsmd.getColumnDisplaySize (i)+10);
            }           
                             
                  // Output the column headings.
            for (int i = 1; i <= columnCount; ++i) {
                 sbf.append(format (rsmd.getColumnLabel(i), columnWidths[i-1] ));
                 sbf.append("\t");
                 
            }           
                  sbf.append("\n");           
                // Output a dashed line.
            StringBuffer dashedLine;
            for (int i = 1; i <= columnCount; ++i) {
                for (int j = 1; j <= columnWidths[i-1]; ++j)
                    
                 sbf.append("-");
                 sbf.append("  \t");
                 
            }
                  sbf.append("\n");   
                       
              // Iterate throught the rows in the result set and output
            // the columns for each row. 
            while (rs.next ()) {
                for (int i = 1; i <= columnCount; ++i) {
                    String value = rs.getString (i);
                    if (rs.wasNull ())
                        value = "<null>";
                     sbf.append(format (value, columnWidths[i-1]));
                     sbf.append("     \t \t \t        ");
                }
                sbf.append("\n");
            }      
            
}
       public String toString(){
      
         return  sbf.toString();     
       }  

  // Format a string so that it has the specified width.
  
       private static String format (String s, int width)
    {
        String formattedString;

        // The string is shorter than specified width,
        // so we need to pad with blanks.
        if (s.length() < width) {
            StringBuffer buffer = new StringBuffer (s);
            for (int i = s.length(); i < width; ++i)
                buffer.append (" ");
            formattedString = buffer.toString();
        }

        // Otherwise, we need to truncate the string.
        else
            formattedString = s.substring (0, width);

        return formattedString;
    }
         
}

Can anyone help me figure how to get this code to display correctly in a JTextArea? I'm using JDBC, we are able to get the code to send over the string buffer to the main class but the format will not display correctly. The first column will display straight as well as the second but after that the format is all sloppy. The strange thing is that we checked the code output into the command line output area and it will format it correctly when you display it in that area but not in the text area. If anyone can help that would be amazing! 

package pkgfinal;
import java.sql.*;

public class connectURL {
    // Declare the JDBC objects.
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String URLQuery;
private ResultSetMetaData rsmd;
private StringBuffer sbf;

 public connectURL(String queryString) throws Exception{
              sbf = new StringBuffer();
            //  sbf.delete(0, sbf.length());
                // URLQuery = query;
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=Final;integratedSecurity=true;";

       
        // Establish the connection.
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = DriverManager.getConnection(connectionUrl);
            String t =queryString;
            // Create and execute an SQL statement that returns some data.
            stmt = con.createStatement();
                       
            rs = stmt.executeQuery(t);
                        rsmd = rs.getMetaData();
       
            int columnCount = rsmd.getColumnCount ();
            String[] columnLabels = new String[columnCount];
            int[] columnWidths = new int[columnCount];
            for (int i = 1; i <= columnCount; ++i) { 
                columnLabels[i-1] = rsmd.getColumnLabel (i);
                columnWidths[i-1] = Math.max (columnLabels[i-1].length(),
                                              rsmd.getColumnDisplaySize (i)+10);
            }           
                             
                  // Output the column headings.
            for (int i = 1; i <= columnCount; ++i) {
                 sbf.append(format (rsmd.getColumnLabel(i), columnWidths[i-1] ));
                 sbf.append("\t");
                 
            }           
                  sbf.append("\n");           
                // Output a dashed line.
            StringBuffer dashedLine;
            for (int i = 1; i <= columnCount; ++i) {
                for (int j = 1; j <= columnWidths[i-1]; ++j)
                    
                 sbf.append("-");
                 sbf.append("  \t");
                 
            }
                  sbf.append("\n");   
                       
              // Iterate throught the rows in the result set and output
            // the columns for each row. 
            while (rs.next ()) {
                for (int i = 1; i <= columnCount; ++i) {
                    String value = rs.getString (i);
                    if (rs.wasNull ())
                        value = "<null>";
                     sbf.append(format (value, columnWidths[i-1]));
                     sbf.append("     \t \t \t        ");
                }
                sbf.append("\n");
            }      
            
}
       public String toString(){
      
         return  sbf.toString();     
       }  

  // Format a string so that it has the specified width.
  
       private static String format (String s, int width)
    {
        String formattedString;

        // The string is shorter than specified width,
        // so we need to pad with blanks.
        if (s.length() < width) {
            StringBuffer buffer = new StringBuffer (s);
            for (int i = s.length(); i < width; ++i)
                buffer.append (" ");
            formattedString = buffer.toString();
        }

        // Otherwise, we need to truncate the string.
        else
            formattedString = s.substring (0, width);

        return formattedString;
    }
         
}

Can anyone help me figure how to get this code to display correctly in a JTextArea? I'm using JDBC, we are able to get the code to send over the string buffer to the main class but the format will not display correctly. The first column will display straight as well as the second but after that the format is all sloppy. The strange thing is that we checked the code output into the command line output area and it will format it correctly when you display it in that area but not in the text area. If anyone can help that would be amazing! 

package pkgfinal;
import java.sql.*;

public class connectURL {
    // Declare the JDBC objects.
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String URLQuery;
private ResultSetMetaData rsmd;
private StringBuffer sbf;

 public connectURL(String queryString) throws Exception{
              sbf = new StringBuffer();
            //  sbf.delete(0, sbf.length());
                // URLQuery = query;
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=Final;integratedSecurity=true;";

       
        // Establish the connection.
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = DriverManager.getConnection(connectionUrl);
            String t =queryString;
            // Create and execute an SQL statement that returns some data.
            stmt = con.createStatement();
                       
            rs = stmt.executeQuery(t);
                        rsmd = rs.getMetaData();
       
            int columnCount = rsmd.getColumnCount ();
            String[] columnLabels = new String[columnCount];
            int[] columnWidths = new int[columnCount];
            for (int i = 1; i <= columnCount; ++i) { 
                columnLabels[i-1] = rsmd.getColumnLabel (i);
                columnWidths[i-1] = Math.max (columnLabels[i-1].length(),
                                              rsmd.getColumnDisplaySize (i)+10);
            }           
                             
                  // Output the column headings.
            for (int i = 1; i <= columnCount; ++i) {
                 sbf.append(format (rsmd.getColumnLabel(i), columnWidths[i-1] ));
                 sbf.append("\t");
                 
            }           
                  sbf.append("\n");           
                // Output a dashed line.
            StringBuffer dashedLine;
            for (int i = 1; i <= columnCount; ++i) {
                for (int j = 1; j <= columnWidths[i-1]; ++j)
                    
                 sbf.append("-");
                 sbf.append("  \t");
                 
            }
                  sbf.append("\n");   
                       
              // Iterate throught the rows in the result set and output
            // the columns for each row. 
            while (rs.next ()) {
                for (int i = 1; i <= columnCount; ++i) {
                    String value = rs.getString (i);
                    if (rs.wasNull ())
                        value = "<null>";
                     sbf.append(format (value, columnWidths[i-1]));
                     sbf.append("     \t \t \t        ");
                }
                sbf.append("\n");
            }      
            
}
       public String toString(){
      
         return  sbf.toString();     
       }  

  // Format a string so that it has the specified width.
  
       private static String format (String s, int width)
    {
        String formattedString;

        // The string is shorter than specified width,
        // so we need to pad with blanks.
        if (s.length() < width) {
            StringBuffer buffer = new StringBuffer (s);
            for (int i = s.length(); i < width; ++i)
                buffer.append (" ");
            formattedString = buffer.toString();
        }

        // Otherwise, we need to truncate the string.
        else
            formattedString = s.substring (0, width);

        return formattedString;
    }
         
}

Can anyone help me figure how to get this code to display correctly in a JTextArea? I'm using JDBC, we are able to get the code to send over the string buffer to the main class but the format will not display correctly. The first column will display straight as well as the second column in the JTextArea but after that the format is all sloppy. The strange thing is that we checked the code output into the command line output area and it will format it correctly when you display it in that area but not in the text area. If anyone can help that would be amazing! 

package pkgfinal;
import java.sql.*;

public class connectURL {
    // Declare the JDBC objects.
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String URLQuery;
private ResultSetMetaData rsmd;
private StringBuffer sbf;

 public connectURL(String queryString) throws Exception{
              sbf = new StringBuffer();
            //  sbf.delete(0, sbf.length());
                // URLQuery = query;
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=Final;integratedSecurity=true;";

       
        // Establish the connection.
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = DriverManager.getConnection(connectionUrl);
            String t =queryString;
            // Create and execute an SQL statement that returns some data.
            stmt = con.createStatement();
                       
            rs = stmt.executeQuery(t);
                        rsmd = rs.getMetaData();
       
            int columnCount = rsmd.getColumnCount ();
            String[] columnLabels = new String[columnCount];
            int[] columnWidths = new int[columnCount];
            for (int i = 1; i <= columnCount; ++i) { 
                columnLabels[i-1] = rsmd.getColumnLabel (i);
                columnWidths[i-1] = Math.max (columnLabels[i-1].length(),
                                              rsmd.getColumnDisplaySize (i)+10);
            }           
                             
                  // Output the column headings.
            for (int i = 1; i <= columnCount; ++i) {
                 sbf.append(format (rsmd.getColumnLabel(i), columnWidths[i-1] ));
                 sbf.append("\t");
                 
            }           
                  sbf.append("\n");           
                // Output a dashed line.
            StringBuffer dashedLine;
            for (int i = 1; i <= columnCount; ++i) {
                for (int j = 1; j <= columnWidths[i-1]; ++j)
                    
                 sbf.append("-");
                 sbf.append("  \t");
                 
            }
                  sbf.append("\n");   
                       
              // Iterate throught the rows in the result set and output
            // the columns for each row. 
            while (rs.next ()) {
                for (int i = 1; i <= columnCount; ++i) {
                    String value = rs.getString (i);
                    if (rs.wasNull ())
                        value = "<null>";
                     sbf.append(format (value, columnWidths[i-1]));
                     sbf.append("     \t \t \t        ");
                }
                sbf.append("\n");
            }      
            
}
       public String toString(){
      
         return  sbf.toString();     
       }  

  // Format a string so that it has the specified width.
  
       private static String format (String s, int width)
    {
        String formattedString;

        // The string is shorter than specified width,
        // so we need to pad with blanks.
        if (s.length() < width) {
            StringBuffer buffer = new StringBuffer (s);
            for (int i = s.length(); i < width; ++i)
                buffer.append (" ");
            formattedString = buffer.toString();
        }

        // Otherwise, we need to truncate the string.
        else
            formattedString = s.substring (0, width);

        return formattedString;
    }
         
}
Wait while more posts are being loaded