title: How can I get the database name I am connected to through Hibernate?
body: <p>I am trying to get the name of the database I am connected to in SQL Server. I tried doing:</p>
  
  <pre><code>Query query = session.createQuery("SELECT db_name()");
  List&lt;String&gt; dbNames = query.list();
  </code></pre>
  
  <p>However, I got the following error:</p>
  
  <pre><code>[ERROR PARSER:35] *** ERROR: &lt;AST&gt;:0:0: unexpected end of subtree
  Exception in thread "main" java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.MethodNode 
   \-[METHOD_CALL] MethodNode: '('
      +-[METHOD_NAME] IdentNode: 'db_name' {originalText=db_name}
      \-[EXPR_LIST] SqlNode: 'exprList'
  </code></pre>
  
  <p>How can I get the name of the database I am connected to?</p>