Sponsored Links


Results 1 to 2 of 2

Thread: tutorial about the practical usage of the SQL 2011

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    Icon19 tutorial about the practical usage of the SQL 2011

    Sponsored Links1


    Respected Sir A.A,

    Sponsored Links

    i have little bit ambiguity in the SQL, that how can i build the database (tables) in it, please give me any tutorial about the practical usage of the SQL.Thaks

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    Code:
    Here is the code to create the table in database, you can modify it according to your needs.
     
    import java.sql.Connection;
    import java.sql.DataTruncation;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLWarning;
    import java.sql.Statement;
    
    public class Main {
      public static void main(String[] args) throws Exception {
        Connection conn = getConnection();
        conn.setAutoCommit(false);
        Statement stmt = conn.createStatement();
    
        stmt.executeUpdate("create table survey (id int, name CHAR(5) );");
    
        stmt.executeUpdate("INSERT INTO survey(id, name)VALUES(111, '123456789')");
    
        // since there were no errors, commit
        conn.commit();
    
        ResultSet rs = stmt.executeQuery("SELECT * FROM survey");
        outputResultSet(rs);
    
        rs.close();
        stmt.close();
        conn.close();
      }
    
      private static void outputResultSet(ResultSet rs) throws Exception {
        ResultSetMetaData rsMetaData = rs.getMetaData();
        int numberOfColumns = rsMetaData.getColumnCount();
        for (int i = 1; i < numberOfColumns + 1; i++) {
          String columnName = rsMetaData.getColumnName(i);
          System.out.print(columnName + "   ");
    
        }
        System.out.println();
        System.out.println("----------------------");
    
        while (rs.next()) {
          for (int i = 1; i < numberOfColumns + 1; i++) {
            System.out.print(rs.getString(i) + "   ");
          }
          System.out.println();
        }
    
      }
    
      private static Connection getConnection() throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          String url = "jdbc:odbc:CourseDSN";
          return DriverManager.getConnection(url);
      }
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Wi-Tribe Net Nanny: Monitor Internet Usage price 2011-12
    By Vuhelper in forum wireless services
    Replies: 0
    Last Post: 09-12-2011, 11:52 PM
  2. When will I be billed for the service usage for Evo 3G
    By Xpert in forum wireless services
    Replies: 0
    Last Post: 07-18-2011, 01:36 AM
  3. Replies: 0
    Last Post: 07-06-2011, 10:12 PM
  4. forex tutorial for earning good up to 1000$ in Pakistan 2011
    By Xpert in forum Currency and Stock Exchange
    Replies: 0
    Last Post: 05-29-2011, 01:21 AM
  5. Replies: 4
    Last Post: 04-30-2011, 01:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft | Jobs