Posts

Showing posts from November, 2020

Database related

Some things that I need to work on, related to Database. These code is used only to solve my needs, not suitable for production. Print data of a table private static void printTableDetails() { String tableName = "Student"; Connection con=null; try { Class.forName("com.vertica.jdbc.Driver"); Properties props = new Properties(); props.put("user", "xxx"); props.put("password", "xxx"); con=DriverManager.getConnection("jdbc:xxx://host:port/",props); System.out.println("### Metadata of table : " + tableName); DatabaseMetaData databaseMetaData = con.getMetaData(); ResultSet columns = databaseMetaData.getColumns(null,null, tableName, null); int count = 1; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from " + tableName); ResultSetMetaD...