Take the 2-minute tour ×
     DatabaseMetaData data = connection.getMetaData();
     resultSet =  data.getCatalogs();
     while (resultSet.next()) {

above code gives me name of all the database of the sql server but i need only default database that configured in DSN

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
Statement statement = connection.createStatement();
    ResultSet resultSet1 = statement.executeQuery("select db_name()");
    while (resultSet1.next()) {
share|improve this answer
add comment

Your Answer


