postgresql - If a data type is numeric in database how to check it's precision and scale using java -


I can verify the name of the column using this code

  connection jdbcConnection = DriverManager .getConnection ("JDBC: PostgreSQL: // localhost: 9823 / postgres", "postgres", "password"); Database Sitadata md = jdbcConnection.getMetaData (); Results set rs = md.getColumn ("Postgres", blank, "my_table", "%"); While (rsnext ()) {System.out.println (rs.getString (4)); }  

How to check the accuracy and scale of a numerical datatype in any column?

You can get column meta data through ResultSetMetaData . You can get meta data as follows:

  ResultSet rset = st.executeQuery ("blah"); Resultsetmetadata md = rset.getMetaData ();  

Once you receive the ResultSetMetaData , call the following to get the exact and scale:

  Int getprision (int column) int GetScale (int column)  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -