Here you can find the source of getIonMassList()
public static List<String[]> getIonMassList() throws IOException
//package com.java2s; /******************************************************************************* * * Copyright (C) 2011 MassBank Project/* w ww. j ava 2s .co m*/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ******************************************************************************* * * ???w???????????[?e?B???e?B?N???X * * ver 1.0.1 2012.11.01 * ******************************************************************************/ import java.util.List; import java.util.ArrayList; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Main { public static List<String[]> getIonMassList() throws IOException { List<String[]> massList = new ArrayList(); try { Class.forName("com.mysql.jdbc.Driver"); String conUrl = "jdbc:mysql://localhost/FORMULA_STRUCTURE_RELATION"; Connection con = DriverManager.getConnection(conUrl, "bird", "bird2006"); Statement stmt = con.createStatement(); String sql = "SELECT FORMULA, MASS FROM ION_MASS order by MASS"; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { String formula = rs.getString("FORMULA"); String mass = rs.getString("MASS"); massList.add(new String[] { formula, mass }); } rs.close(); stmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } return massList; } }