SlideShare a Scribd company logo
1 of 6
package com.nt.gui;
importjava.awt.BorderLayout;
importjava.awt.Color;
importjava.awt.FlowLayout;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DatabaseMetaData;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.ResultSetMetaData;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JComboBox;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
publicclassDBTool extendsJFrame implementsActionListener{
private JLabel luser,ldb,ltable,lcolumn;
private JComboBox jcuser,jcdb,jctable,jccolumn;
//declaringothervariables..
private Connectioncon,con4;
private Statementst,st4,st5,st6;
private ResultSetrs,rs4,rs5,rs6;
//declaringmetadatavariables..
private ResultSetMetaDatarsmd;
private intcocnt1;
//constructorstarts
DBTool() throwsException
{
setTitle("MAGICALDATABASETOOL");
setSize(600,500);
setLocation(300,150);
setBackground(Color.WHITE);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
//configuringthe containeritems throughJPanel
JPanel p=newJPanel();
setLayout(null);
add(p);
//settinggridlayout...
p.setLayout(newGridLayout(4,2,8, 8));
p.setBounds(70,65,400, 280);
luser=newJLabel("ALLUSERS/SCHEMAS");
p.add(luser);
jcuser=newJComboBox();
jcuser.addActionListener(this);
p.add(jcuser);
ldb=newJLabel("LOGICALNAME");
p.add(ldb);
jcdb=newJComboBox();
jcdb.addActionListener(this);
p.add(jcdb);
ltable=new JLabel("TABLENAME");
p.add(ltable);
jctable=newJComboBox();
jctable.addActionListener(this);
p.add(jctable);
lcolumn=newJLabel("COLUMN NAME");
p.add(lcolumn);
jccolumn=newJComboBox();
jccolumn.addActionListener(this);
p.add(jccolumn);
setVisible(true);
//registeringdriversandcreatingconnection
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system",
"password");
System.out.println(con.getClass().getName());
//creatingStatementobject
st = con.createStatement();
//gettingschemasandputtingincombobox 1
rs = st.executeQuery("selectusername fromdba_users");
int cnt1=0;
while (rs.next()) {
jcuser.addItem(rs.getString(1));
cnt1++;
}
System.out.println("Total noof Schemas: "+cnt1);
}//constructor
//mainmethod
publicstaticvoidmain(String[] args) throwsException{
newDBTool();
}//endmain
@Override
publicvoidactionPerformed(ActionEvente) {
if(jcuser==(JComboBox)e.getSource())
{//removingpreviousresults
jcdb.removeAllItems();
jctable.removeAllItems();
jccolumn.removeAllItems();
//gettingusertable selectedschemaitemintoone Objectvariable
Objectselected=jcuser.getSelectedItem();
try {
//generatingconditionthatif the selecteditemequalstothe url
if(selected.equals(selected)){
//gettingpasswordfromuseratrun time throughJOptionPane
StringinputValue =JOptionPane.showInputDialog(this,"PleaseEnterValidPassword");
//creatingnew Connectionw.r.t.targeturl andpassword
con4=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl",selected.toString(),inpu
tValue);
//gettinglogical DBname andputtingto combobox 2
st4 = con4.createStatement();
rs4 = st4.executeQuery("select*from global_name");
int cnt2=0;
while (rs4.next()) {
jcdb.addItem(rs4.getString(1));
cnt2++;
}
System.out.println("Total noof Logiacl Dbname: "+cnt2);
//gettingtable namesandputtingtocombobox 3
st5 = con4.createStatement();
rs5 = st5.executeQuery("selecttable_namefromtabs");
int cnt3=0;
while (rs5.next()) {
jctable.addItem(rs5.getString(1));
cnt3++;
}
System.out.println("Total noof Table Name: "+cnt3);
}//if
}//try
catch (Exceptione1) {e1.printStackTrace();}
}//outerif
//.................logicforgettingcolumnnamesfromjctable combobox ...................
if(jctable==(JComboBox)e.getSource())
{
//removingpreviousresults
jccolumn.removeAllItems();
//gettingcolumnnamesandputingtocombobox 4
try {
//preparationforgettingtable name atruntime
Strings=(String)jctable.getSelectedItem();
st6 = con4.createStatement();
Stringqry="select* from"+s;
//gettingresultsintoResultSet
rs6 = st6.executeQuery(qry);
//creatingMetaData obj
rsmd=rs6.getMetaData();
//gettingcolumncountinResultSetMetaData
int cocnt1=rsmd.getColumnCount();
int cnt=0;
//addingresultstocombobox 4
for(inti=1;i<=cocnt1;++i){
jccolumn.addItem(rsmd.getColumnLabel(i));
cnt++;
}
System.out.println("Total noof Columns: "+cnt);
}//try
catch (Exception e2) {e2.printStackTrace();}
}//if
}//actionPerformed()
}//class

More Related Content

What's hot

Evan Schultz - Angular Camp - ng2-redux
Evan Schultz - Angular Camp - ng2-reduxEvan Schultz - Angular Camp - ng2-redux
Evan Schultz - Angular Camp - ng2-redux
Evan Schultz
 
Photo Insert and Retrieve App
Photo Insert and Retrieve AppPhoto Insert and Retrieve App
Photo Insert and Retrieve App
Peeyush Ranjan
 

What's hot (20)

Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Using React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIsUsing React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIs
 
Getting started with ReactJS
Getting started with ReactJSGetting started with ReactJS
Getting started with ReactJS
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenment
 
Evan Schultz - Angular Camp - ng2-redux
Evan Schultz - Angular Camp - ng2-reduxEvan Schultz - Angular Camp - ng2-redux
Evan Schultz - Angular Camp - ng2-redux
 
React on es6+
React on es6+React on es6+
React on es6+
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
 
Redux vs Alt
Redux vs AltRedux vs Alt
Redux vs Alt
 
React lecture
React lectureReact lecture
React lecture
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
Custom Action Framework
Custom Action FrameworkCustom Action Framework
Custom Action Framework
 
Photo Insert and Retrieve App
Photo Insert and Retrieve AppPhoto Insert and Retrieve App
Photo Insert and Retrieve App
 
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...
 
Creating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with ReactCreating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with React
 
ProvJS: Six Months of ReactJS and Redux
ProvJS:  Six Months of ReactJS and ReduxProvJS:  Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
 
Asyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaAsyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-saga
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
 
Modern Web Developement
Modern Web DevelopementModern Web Developement
Modern Web Developement
 
React js t7 - forms-events
React js   t7 - forms-eventsReact js   t7 - forms-events
React js t7 - forms-events
 

Similar to DBTool

import java.awt.BorderLayout; import java.awt.EventQueue; i.pdf
  import java.awt.BorderLayout;     import java.awt.EventQueue;      i.pdf  import java.awt.BorderLayout;     import java.awt.EventQueue;      i.pdf
import java.awt.BorderLayout; import java.awt.EventQueue; i.pdf
nikhilpopli11
 
correct the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdfcorrect the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdf
devangmittal4
 
correct the error and add code same in the pic import jav.pdf
correct the error and add code same in the pic   import jav.pdfcorrect the error and add code same in the pic   import jav.pdf
correct the error and add code same in the pic import jav.pdf
devangmittal4
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
arvindarora20042013
 
codigomenu-1 (1).docx
codigomenu-1 (1).docxcodigomenu-1 (1).docx
codigomenu-1 (1).docx
AnaLpez275
 
codigomenu-1.docx
codigomenu-1.docxcodigomenu-1.docx
codigomenu-1.docx
AnaLpez275
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdf
fashionfolionr
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
Tse-Ching Ho
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
anushkaent7
 
Servlet LifeCycle Demo App
Servlet LifeCycle Demo  AppServlet LifeCycle Demo  App
Servlet LifeCycle Demo App
Peeyush Ranjan
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
AliHaiderCheema2
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
sudhirchourasia86
 

Similar to DBTool (20)

Scrollable Demo App
Scrollable Demo AppScrollable Demo App
Scrollable Demo App
 
import java.awt.BorderLayout; import java.awt.EventQueue; i.pdf
  import java.awt.BorderLayout;     import java.awt.EventQueue;      i.pdf  import java.awt.BorderLayout;     import java.awt.EventQueue;      i.pdf
import java.awt.BorderLayout; import java.awt.EventQueue; i.pdf
 
correct the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdfcorrect the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdf
 
correct the error and add code same in the pic import jav.pdf
correct the error and add code same in the pic   import jav.pdfcorrect the error and add code same in the pic   import jav.pdf
correct the error and add code same in the pic import jav.pdf
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
codigomenu-1 (1).docx
codigomenu-1 (1).docxcodigomenu-1 (1).docx
codigomenu-1 (1).docx
 
codigomenu-1.docx
codigomenu-1.docxcodigomenu-1.docx
codigomenu-1.docx
 
Hacking the Codename One Source Code - Part III - Transcript.pdf
Hacking the Codename One Source Code - Part III - Transcript.pdfHacking the Codename One Source Code - Part III - Transcript.pdf
Hacking the Codename One Source Code - Part III - Transcript.pdf
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdf
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 
Scrollable Test App
Scrollable Test AppScrollable Test App
Scrollable Test App
 
Hacking the Codename One Source Code - Part III.pdf
Hacking the Codename One Source Code - Part III.pdfHacking the Codename One Source Code - Part III.pdf
Hacking the Codename One Source Code - Part III.pdf
 
TextSearch
TextSearchTextSearch
TextSearch
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 
FlowRateGUI
FlowRateGUIFlowRateGUI
FlowRateGUI
 
Servlet LifeCycle Demo App
Servlet LifeCycle Demo  AppServlet LifeCycle Demo  App
Servlet LifeCycle Demo App
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Speed up your GWT coding with gQuery
Speed up your GWT coding with gQuerySpeed up your GWT coding with gQuery
Speed up your GWT coding with gQuery
 

More from Peeyush Ranjan

Multiple Submit Button Test App
Multiple Submit Button Test AppMultiple Submit Button Test App
Multiple Submit Button Test App
Peeyush Ranjan
 
Multiple Hyperlinks App
Multiple Hyperlinks AppMultiple Hyperlinks App
Multiple Hyperlinks App
Peeyush Ranjan
 
Online Form Submission App
Online Form Submission AppOnline Form Submission App
Online Form Submission App
Peeyush Ranjan
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
Peeyush Ranjan
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
Peeyush Ranjan
 

More from Peeyush Ranjan (7)

Multiple Submit Button Test App
Multiple Submit Button Test AppMultiple Submit Button Test App
Multiple Submit Button Test App
 
Multiple Hyperlinks App
Multiple Hyperlinks AppMultiple Hyperlinks App
Multiple Hyperlinks App
 
Online Form Submission App
Online Form Submission AppOnline Form Submission App
Online Form Submission App
 
Cursor Demo App
Cursor Demo AppCursor Demo App
Cursor Demo App
 
Batch processing Demo
Batch processing DemoBatch processing Demo
Batch processing Demo
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
 

DBTool