Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
Retrive Data Base names from Table Space
raktim banerjee
Greenhorn
Posts: 18
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello Sir!
I am trying to show all the Data Base names in a particule user's account. Is it possible to retrive Table Space information? If possible, then please help me out. I am using MYSQL and
Servlet
.
Souvik Dasgupta
Ranch Hand
Posts: 113
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Raktim,
You can use con.getMetaData( ). It returns Database metadata.
[con is the connection obj.].
Thanks and Regards
Souvik
Thanks and Regards
Souvik
SCJP, SCWCD, OCEJWSD
Souvik Dasgupta
Ranch Hand
Posts: 113
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Raktim,
Please refer to the below code:
import java.sql.*; public class DBApp { public static void main(String args[])throws Exception { Connection conn=null; conn=DBUtil.createConnection(); DatabaseMetaData dbmd = conn.getMetaData(); String dbP = dbmd.getDatabaseProductName(); System.out.println("DB::"+dbP); ResultSet tables = dbmd.getTables("", "", "", null); while (tables.next()) { System.out.println(tables.getString(3)); } } }
Thanks and Regards
Souvik
SCJP, SCWCD, OCEJWSD
raktim banerjee
Greenhorn
Posts: 18
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I do not want the names of the tables in a particular Database.
I want to see all the Database names under a particular user name.
raktim banerjee
Greenhorn
Posts: 18
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I found the solution:
Connection con; Statement st=null; ArrayList db = new ArrayList(); PrintWriter pw = response.getWriter(); ResultSet rs,rs1; String dbm,tables; try{ dbm=request.getParameter("db"); Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/rak?user=root&password=password"); DatabaseMetaData meta = con.getMetaData(); ResultSet schemas = meta.getCatalogs(); while (schemas.next()) { System.out.println( schemas.getString("TABLE_CAT") ); } }catch(Exception e) { e.printStackTrace(); }
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
retrieve table name
Struts
How to store image in mysql database
how to retrive data from data base put in HTML PAGE as report
Populate the data into an ArrayList
More...