Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Problem Authenticating through JDBC running on Linux. - response (3) by sreevaddi

$
0
0
private static String user = "tduser"; private static String password = "passwd"; private static String url = "jdbc:teradata://TDServer/TMODE=ANSI,CHARSET=UTF8"; private String sqlGetData = "SELECT * FROM dbc.tables WHERE databasename='<dbname>'"; public static void getData(String sqlGetData) { Statement statement = null; Connection connection = null; ResultSet resultSet = null; try { Class.forName("com.teradata.jdbc.TeraDriver"); connection = DriverManager.getConnection(url, user, password); statement = connection.createStatement(); resultSet = statement.executeQuery(sqlGetData); ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); int columnCount = resultSetMetaData.getColumnCount(); for (int i=1; i<=columnCount; i++) { System.out.print(resultSetMetaData.getColumnName(i).toUpperCase() + ","); } System.out.println(""); while (resultSet.next()) { for (int i=1; i<=columnCount; i++) { System.out.print(resultSet.getString(i) + ","); } System.out.println(""); } } catch (SQLException | ClassNotFoundException e) { e.printStackTrace(); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } }

Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>