Java JDBC MySQL Connection getMaxID()

Here you can find the source of getMaxID()

Description

get Max ID

License

Open Source License

Declaration

public static int getMaxID() throws SQLException 

Method Source Code

//package com.java2s;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
    static String JDBC_URL = "jdbc:mysql://localhost/rssminer?cachePrepStmts=true&useServerPrepStmts=true";

    public static int getMaxID() throws SQLException {
        Connection con = getRssminerDB();
        Statement stat = con.createStatement();
        ResultSet rs = stat.executeQuery("select max(id) from feed_data");
        rs.next();//from  w  w w  .  j ava2  s  . c o  m
        int max = rs.getInt(1);
        con.close();
        return max;
    }

    public static Connection getRssminerDB() throws SQLException {
        Connection con = DriverManager.getConnection(JDBC_URL, "feng", "");

        return con;
    }
}

Related

  1. getDMPConn()
  2. getGoogleCloudDBConnection()
  3. getIonMassList()
  4. getJdbcConnection(String host, int port, String name, String user, String password)
  5. getJtdsConnection()
  6. getMysqlCon(String ip, String port, String dbname, String username, String password)
  7. getMysqlConnection(final String url)
  8. getMySQLConnection(Properties props)
  9. getMySQLConnection(String cloudSqlInstance, String dbName, String userName, String password)