Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  

global jdbc file



Share on Google+Share on Google+

global jdbc file
1 Answer(s)      6 years ago
Posted in : JDBC

hi, I want to create a global connection file by using function like getConnection(),startConnection(), and stopConnection() etc. so anybody from my team can access that class file. can anybody help me out for the same.

Thanks in advance.

View Answers

August 24, 2011 at 2:04 PM

import java.sql.*;

class DatabaseConnection{
  public static Connection getConnection() throws Exception {
    String driver = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost:3306/test";
    String username = "root";
    String password = "root";
    return DriverManager.getConnection(url, username, password);
public class GetConnection {
  public static void main(String[] args) throws Exception {
    Connection conn = DatabaseConnection.getConnection();
    Statement st = conn.createStatement();
    ResultSet rs = st.executeQuery("SELECT * FROM data");
    System.out.println(rs.getString("name")+" \t "+rs.getString("address"));


Related Tutorials/Questions & Answers:
global jdbc file
global jdbc file  hi, I want to create a global connection file.... so anybody from my team can access that class file. can anybody help me out... driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost
xml configuration file - JDBC
a xml configuration file . We have mysql database in some other system. I have to access the data from different system. For this jdbc connectivity how to create a xml file. Please help me out. Thank you  Hi Friend, Try
exe file creation - JDBC
exe file creation   hi i have done a project in java swings.project name is format migrator.means db migrator. now my aim is create EXE FILE for my project. pls do consider
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same... used JDBC ODBC to read from excel file. i am not able to append it using
upload ,download and update file document - JDBC
upload ,download and update file document   hi sir.i am creating one application in jsp in which i need to upload the word document file which... to upload the word file: 1)page.jsp Display file upload form
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file
global variable in objective c
global variable in objective c  Declaring global variable in objective c
Access Excel file through JDBC
Access Excel file through JDBC In this section, you will learn how to access excel file through Jdbc and display records in JTable. As you know Excel comes with an ODBC driver, so we are using JDBC-ODBC bridge driver to connect jdbc
creating a global variable with php
creating a global variable with php  Is it possible to create a variable to declare as global in case of database connectivity?   Yes... below.. function processlogin($username, $password){     global $database
Expport data into CSV File using JDBC in Servlet
into CSV File using JDBC in Servlet   ... into CSV file using JDBC in Servlet. We have created  file "" to export data from database in to CSV file. Brief
PHP Global Variable
PHP  Global Variable To access global variable in PHP we need to use global keyword or $GLOBALS associative array global is a keyword which helps us to access the globally declared variable. There is no limit to use global
JDBC  why we use batch in jdbc
jdbc  display the records using index in jdbc
jdbc  Hai , Give a steps for jdbc connectivity
jdbc  how can i store the image file and retrive the images from... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); File imgfile = new File("C:/flower.jpg"); FileInputStream fin = new
JDBC  How to add set of queries in a single query in JDBC
how i can access Microsoft Access database by java program  how i can access Microsoft Access database by java program ? if any package or jar file...("jdbc:odbc:student"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
jdbc  please tell me sir.i dont know JDBC connection and how to create table in database
jdbc   how to write program to save data and retrieve data from the form in Java
jdbc  why do we need to load jdbc drivers before connecting to database
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector
JDBC  in class.forname which driver name we are writing for the connection from jdbc to sqlserver 2008
jdbc  is it possible to use doget & dopost method with jdbc to call in a servlet programe
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
JDBC  can u send me the code of jdbc how to join two tables that are in relation
jdbc define batch updates  define batch updates?exp   JDBC... links:
jdbc  Write a web based student registration application where the students can register online with their enrollment no. You are required to use JSP, Servelet and JDBC
jdbc - JDBC
Why JDBC   JDBC used for what
JDBC - limitations of jdbc  What are the limitations of JDBC
JDBC save a data in the database  I need a code to save a data... between java and mysql using JDBC and saves the data into the database. import... con = null; String url = "jdbc:mysql://localhost:3306/"; String db