com.antiaction.raptor.sql.mssql.MSSql_Language Maven / Gradle / Ivy
/*
* Created on 24/02/2010
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.antiaction.raptor.sql.mssql;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.antiaction.raptor.i18n.Language;
public class MSSql_Language {
private static Logger logger = Logger.getLogger( MSSql_Language.class.getName() );
public static List getLanguages(Connection conn) {
List languages = new ArrayList();
Language language;
String sql;
PreparedStatement stm = null;
ResultSet rs = null;
try {
sql = "SELECT id, culture_name, display_name, culture_code, iso_639x FROM languages ";
stm = conn.prepareStatement( sql );
stm.clearParameters();
rs = stm.executeQuery();
while ( rs.next() ) {
language = new Language();
language.id = rs.getInt( 1 );
language.culture_name = rs.getString( 2 );
language.display_name = rs.getString( 3 );
language.culture_code = rs.getInt( 4 );
if ( rs.wasNull() ) {
language.culture_code = -1;
}
language.iso_639x = rs.getString( 5 );
languages.add( language );
}
rs.close();
rs = null;
stm.close();
stm = null;
}
catch (SQLException e) {
languages = null;
logger.log( Level.SEVERE, e.toString(), e );
}
finally {
if ( rs != null ) {
try {
rs.close();
}
catch (SQLException e) {
logger.log( Level.SEVERE, e.toString(), e );
}
rs = null;
}
if ( stm != null ) {
try {
stm.close();
}
catch (SQLException e) {
logger.log( Level.SEVERE, e.toString(), e );
}
stm = null;
}
}
return languages;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy