Created
November 13, 2014 11:18
-
-
Save matiasfha/ffd7c54083963c0502df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Statement stmt = null; | |
String query = | |
"select attr1, attr2 from TU_TABLA"; | |
try { | |
stmt = con.createStatement(); | |
ResultSet rs = stmt.executeQuery(query); | |
while (rs.next()) { | |
String attr1 = rs.getString("attr1"); | |
int attr2 = rs.getInt("attr2"); | |
mijTextField.setText(attr1); | |
//Si lo que se busca es concatenar dos valores obtenidos de la BD | |
//y asignarlos a un jTextField se puede utilizar simplemente | |
//la concatenacion con "+" o con String.format | |
jTextField2.setText(String.format("%s %i",attr1,attr2)); | |
} | |
} catch (SQLException e ) { | |
JDBCTutorialUtilities.printSQLException(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment