Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.spec;
- import com.spec.model.Person;
- import com.spec.service.ProductService;
- import com.spec.util.DataBaseUtil;
- import java.sql.Connection;
- import java.sql.DatabaseMetaData;
- import java.sql.SQLException;
- import java.util.List;
- public class Test {
- // получим инофрмацию о версии СУБД и версии драйвера
- public static void printMeta() {
- // после работы с объектом типа Connection необходимо его закрыть - вызвать метод close
- // try-with-resources
- try (Connection c = DataBaseUtil.getConnection()) {
- DatabaseMetaData m = c.getMetaData();
- //
- System.out.println("m.getDatabaseProductName()=" + m.getDatabaseProductName());
- System.out.println("m.getDatabaseProductVersion()=" + m.getDatabaseProductVersion());
- System.out.println("m.getJDBCMajorVersion()=" + m.getJDBCMajorVersion());
- System.out.println("m.getDriverName()=" + m.getDriverName());
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- /*finally{
- c.close()
- }*/
- }
- //
- public static void main(String[] args) {
- // try {
- // Connection c = DataBaseUtil.getConnection();
- // System.out.println("c=" + c);
- // } catch (SQLException ex) {
- // ex.printStackTrace();
- // }
- printMeta();
- ProductService service = new ProductService();
- try {
- List<Person> list = service.getAll();
- System.out.println("list.size=" + list.size());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement