Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37250

Re: Which databases are the most used with Java

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.java.programmer
Subject Re: Which databases are the most used with Java
Date Tue, 15 Aug 2017 18:38:15 +0200
Organization Decebal Computing
Lines 63
Message-ID <87tw18n5vs.fsf@munus.decebal.nl> (permalink)
References <87y3qovwjb.fsf@munus.decebal.nl> <omovh9$ad2$1@news.albasani.net> <87tw1bx2c9.fsf@munus.decebal.nl> <slrnop0881.o2q.avl@logic.at> <87a833wzcx.fsf@munus.decebal.nl> <evbal8Fs681U1@mid.individual.net> <87pobz9yv5.fsf@munus.decebal.nl> <afdc32bc-17ff-4ee9-ade0-c7345f805585@googlegroups.com> <87h8x9pfi8.fsf@munus.decebal.nl> <omukv5$m10$1@newsreader4.netcologne.de> <877ey5ngtu.fsf@munus.decebal.nl> <6b0c0b97-8517-4f08-b512-fc3f3054fbb6@googlegroups.com> <87378soq8a.fsf@munus.decebal.nl> <54246758-9876-4f41-a7ac-c2fff223a9e0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="72fb8bea0235c6b94245dccb186de60d"; logging-data="1655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Uhch0JPyPud40tXRVXkZxNZtEhtM838M="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
X-Homepage http://www.decebal.nl/
Cancel-Lock sha1:ld0N3HfZZpaxbeHgN6XJi16OKS4= sha1:34i7icecXbOBB9LTi64EVXqHknI=
Xref csiph.com comp.lang.java.programmer:37250

Show key headers only | View raw


Eric Douglas <e.d.programmer@gmail.com> writes:

>      public static void main(final String[] args) {
>           try {
>                Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
>                Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
>                ResultSet rs = stmt.executeQuery("SELECT table_name FROM information_schema.tables");
>                System.out.println(stmt.getClass());
>                rs.last();
>                System.out.println(rs.getRow());
>                rs.close();
>                rs = stmt.executeQuery("SELECT name from sys.columns");
>                rs.last();
>                System.out.println(rs.getRow());
>                rs.close();
>                stmt.close();
>                conn.close();
>           } catch (SQLException e) {
>                e.printStackTrace();
>           }
>      }

I would not write it like that. At least like this:
    public static void main(final String[] args) {
        try (Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
             Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)){
            try (ResultSet rs = stmt.executeQuery("SELECT table_name FROM information_schema.tables")) {
                System.out.println(stmt.getClass());
                rs.last();
                System.out.println(rs.getRow());
            }
            try (ResultSet rs = stmt.executeQuery("SELECT name from sys.columns")) {
                rs.last();
                System.out.println(rs.getRow());
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

But I do not like this kind of code, so I would rewrite it to:
    public static void main(final String[] args) {
        try (Connection conn      = DriverManager.getConnection(db_connect_string, db_userid, db_password);
             Statement stmtTable  = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
             ResultSet rsTable    = stmt.executeQuery("SELECT table_name FROM information_schema.tables");
             Statement stmtColumn = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
             ResultSet rsColumn   = stmt.executeQuery("SELECT name from sys.columns")){
            System.out.println(stmtTable.getClass());
            rsTable.last();
            System.out.println(rsTable.getRow());
            rsColumn.last();
            System.out.println(rsColumn.getRow());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

And I do not mind to get rid of those Statements.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 07:58 +0200
  Re: Which databases are the most used with Java Marcel Mueller <news.5.maazl@spamgourmet.org> - 2017-08-13 09:33 +0200
    Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 11:14 +0200
    Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:53 -0400
  Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-13 09:36 +0200
    Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 11:07 +0200
      Re: Which databases are the most used with Java Andreas Leitgeb <avl@logic.at> - 2017-08-13 09:46 +0000
        Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 12:12 +0200
          Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-13 17:47 +0200
            Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 19:11 +0200
              Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-13 20:26 +0200
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 21:30 +0200
                Re: Which databases are the most used with Java Martin Gregorie <martin@address-in-sig.invalid> - 2017-08-13 20:00 +0000
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:43 -0400
              Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:42 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 23:18 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 20:41 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 03:04 +0200
                Re: Which databases are the most used with Java lewbloch@gmail.com - 2017-08-14 11:12 -0700
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-14 12:42 -0700
                Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-21 22:25 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-21 19:50 -0400
              Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-14 13:48 -0700
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 07:27 +0200
                Re: Which databases are the most used with Java Martin Gregorie <martin@address-in-sig.invalid> - 2017-08-15 10:25 +0000
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 14:15 +0200
                Re: Which databases are the most used with Java Martin Gregorie <martin@address-in-sig.invalid> - 2017-08-15 14:37 +0000
                Re: Which databases are the most used with Java lewbloch@gmail.com - 2017-08-17 14:52 -0700
                Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-18 00:09 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-17 18:14 -0400
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-17 18:19 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 06:43 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:02 -0400
                Re: Which databases are the most used with Java Patrick Roemer <sangamon@netcologne.de> - 2017-08-15 13:12 +0200
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 14:41 +0200
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-15 06:11 -0700
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 16:33 +0200
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-15 08:05 -0700
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 18:48 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:12 -0400
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-15 08:19 -0700
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:46 -0400
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-15 08:43 -0700
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:51 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 18:38 +0200
                Re: Which databases are the most used with Java Patrick Roemer <sangamon@netcologne.de> - 2017-08-15 16:14 +0200
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 17:42 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:09 -0400
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-15 11:06 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 18:42 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-16 21:13 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-17 09:04 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-17 18:16 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 06:51 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-18 08:52 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 15:31 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-18 15:09 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 23:14 +0200
                Re: Which databases are the most used with Java Eric Douglas <e.d.programmer@gmail.com> - 2017-08-18 07:15 -0700
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-18 15:16 -0400
      Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-13 18:08 +0200
        Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-13 20:30 +0200
          Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 21:35 +0200
            Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-13 22:24 +0200
              Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 23:33 +0200
                Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-14 18:18 +0200
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 07:47 +0200
              Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-16 21:21 -0400
                Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-17 23:33 +0200
                Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-17 18:11 -0400
            Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 23:24 +0200
              Re: Which databases are the most used with Java Robert Klemme <shortcutter@googlemail.com> - 2017-08-14 18:14 +0200
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-15 07:45 +0200
          Re: Which databases are the most used with Java Sebastian <nowhere@nirvana.org> - 2017-08-13 22:16 +0200
          Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:50 -0400
            Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 23:35 +0200
              Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 21:14 -0400
                Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 10:24 +0200
        Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:45 -0400
          Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 23:36 +0200
            Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 20:42 -0400
              Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 03:06 +0200
      Re: Which databases are the most used with Java lewbloch@gmail.com - 2017-08-13 09:59 -0700
      Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 17:04 -0400
        Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 00:06 +0200
          Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 00:35 +0200
            Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 20:44 -0400
              Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-14 03:12 +0200
  Re: Which databases are the most used with Java Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:59 -0400
  Re: Which databases are the most used with Java Joerg Meier <joergmmeier@arcor.de> - 2017-08-16 07:26 +0200
    Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-16 09:40 +0200
  Re: Which databases are the most used with Java Graeme Geldenhuys <graemeg@example.net> - 2017-08-23 00:15 +0100
    Re: Which databases are the most used with Java Cecil Westerhof <Cecil@decebal.nl> - 2017-08-23 12:09 +0200

csiph-web