Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC database connectivity

Have Programming Question? Ask it here!
 
 
 


shiran
database connectivity
2 Answer(s)      5 years and 11 months ago
Posted in : JDBC



Advertisement
View Answers

October 1, 2008 at 2:00 PM


Hi friend,

Code for connecting Mysql database using java :

import java.sql.*;

public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "databasename";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

For more information on JDBC in java visit to :

http://www.roseindia.net/jdbc/

Thanks


February 15, 2011 at 6:46 PM


its working



Related Tutorials/Questions & Answers:
database connectivity - JDBC
database connectivity  can u ppl pls provide me with database connectivity programs with MSacces   Hi Friend, If you havn't create your... a user DSN 4. Select Microsoft Access Driver(*.mdb) 5. Select database name
database connectivity in java - JDBC
database connectivity in java  import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; class Project implements ActionListener { JFrame f; JPanel p1,p2,p3; JTabbedPane
Advertisements
database connectivity - JDBC
database connectivity  example java code for connecting Mysql database using java  Hi friend, Code for connecting Mysql database using...+dbName,userName,password); System.out.println("Connected to the database
Help me on database connectivity in J2ME - Java Beginners
Help me on database connectivity in J2ME  i want help in J2ME. i want code for database connection with MySQL. spcl to fecth and insert data from databse. please help me
JDBC, Java Database Connectivity
tutorials. Java Database Connectivity or JDBC for short is Java bases API... driver as per your application needs. About JDBC Java Database Connectivity... to database and then get the database information. After making a connection
How to Create and display Reports in Java with Database connectivity - Java Beginners
How to Create and display Reports in Java with Database connectivity  Hello Sir , I have Created Student Admission Form with Swing and MS Access 2007 Database Connection,when i will click on Print button it shows the report
Check Whether Record is already Exists or Not with Database Connectivity - Java Beginners
Check Whether Record is already Exists or Not with Database Connectivity ... in the database with Swing Application ,if It is Already Exists then I want To Show MsgBox else that will Store in Database. plz Help Me Sir  Hi Friend, Try
ZF DB Connectivity
ZF Database Connectivity: In this current tutorial we will study how to connect with the database and how to retrieve values from the database. The connectivity with database, declaring table etc. and other activities like
Eclipse Connectivity - JDBC
Eclipse Connectivity  Hello Friends.. I want to do connectivity with eclipse 3.4 Genemade with mysql Database. can u please help me to how to do connectivity..and which plugins are required for it. i have try to do
DB connectivity - EJB
DB connectivity  DB connectivity
connectivity - JDBC
connectivity  I hav MySQL 5.0, JDK 1.5, Tomcat 5.0 in my system when I tried to connect to database and insert data it is showing exeception as follows ------------------------------------------------------------------- type
jsp page connectivity with oracle - SQL
jsp page connectivity with oracle  I am unable to database connectivity jsp with oracle. Please send the code for solving problem. thanks ...: Class.forName("oracle.jdbc.driver.OracleDriver"); 3) Connect to database
Check PHP MySQL Connectivity
Check PHP MySQL Connectivity: The first step of any kind of connectivity is to check whether the connectivity has been established or not. To check the connectivity we need to know three things: The host name, Username, and respective
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been... to store data into sql database the connection does not get established. I am
java to excel connectivity - Swing AWT
.) that are on the jpanel to the database created in MSEXCEL 2007. actually i am... database on the excel.  Hi Friend, Follow these steps: 1. Open Data
audio files in jdbc connectivity with ms-access - JDBC
audio files in jdbc connectivity with ms-access  i need to know how to retrieve audio files through jdbc connectivity with ms-access and how to play them through link in browser....  Hi Friend, Try the following code
Database - WebSevices
Database   Hello, Any one know the detail Database Structure for creating new job site with features.   Hi friend, Plz give full details and requirement to solve the problem and visit to : http
jsp database
jsp database   I want to retrive value in my jsp page but i dont want show my database query in my jsp page. is there any other method to show value in my jsp page using java class
database - SQL
database  For ex: Suppose there is 1000 questions (records) in my database. In my home page i want to display everyday 1 question as day of the question.It should not get change until date change...   Hi friend
error in accessing database - JSP-Servlet
database to the servlet i hv succeeded in connectivity but im stuck to nother... database cud ne1 help me out plss  Hi friend, Code to help in solving... to the database"); conn.close(); System.out.println("Disconnected from database
What is database replication?
What is database replication?  What is database replication?   Hi, Database replication is the creation and maintenance of multiple copies of the same database. In most implementations of database replication, one
Database programming - Java Beginners
Database programming  How to do a Database programing with Balanced Multiway Tree(B+ Tree,not Binary Tree) in java
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
J2ME with Database Connection - MobileApplications
J2ME with Database Connection  I'm using SonyEricssion Java ME SDk for CLDC with WTK2. Can u give me a sample program for Database Connection using MS-Access with MIDlet code
connec to database - JSP-Servlet
connec to database  Need code to connect the application to database. I have developed the application JSP and Servlet
Database - Java Beginners
Database  How to do database connection when using weblogic server? Any specific condition or difference
database - JSP-Servlet
database  how to downloaad a file(doc) from database and store in any local system by using servlet
AJAX- Database not connected - Ajax
AJAX- Database not connected  Respected Sir/Madam, I am Ragavendran.R.. I am working with AJAX and Database.. Ajax code works fine but the database values are not retrieved if queried.. Instead, I could receive
ImadeAdding In dataBASE - Struts
ImadeAdding In dataBASE  Dear Friends Can u tell me how to store imaage in sql database using Struct 1.2.
database retrieving - JDBC
database retrieving  how to retrieve resultset from table which we have created in 'SQL SERVER MANAGEMENT STUDIO' using java program
image store in database - JDBC
into the database what is the process to do that? Please explain...; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert... to store image into database. Check at http://www.roseindia.net/servlets/insert
upload to database - JSP-Servlet
to upload a pdf file into database(sqlserver2000) using jsp. In roseindia some examples... into database whenever i want that uploaded pdf file i have to retrieve it from database please help me friends thanks in advance it is very urgent
Database Error - Hibernate
Database Error  Hi, I am working with Struts 1.2---- AJAX-----Hibernate 3.0 --- MySQL 5.0. At the time of inserting/fetching from Database... exceeded; try restarting transaction That means the database becomes locked. Can
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links: Insert Data Delete Data Thanks
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
Connection to database - Java Beginners
on a Project on Jsp We hve some JSP Pages & trying to connect to our Database . We are using SQL server 2000 ? We are not able to connect our database Tables.../connect_jsp_with_mysql.shtml Because, we didn't use sql server 2000 database
j2me database - MobileApplications
j2me database  hi can anyone tell is there any possibility of connecting database in j2me application..if so, how can i connect it..please help me
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page. Please read at http
Applet database access - Applet
Applet database access  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system... but when its in the server, we r getting null values in the local system.. I
database connection - SQL
database connection  hi friends, This is poornima i want to connect sql server to my eclipse editer how to connect and where i have to write code...-database connection in eclipse IDE? Thanks
MySql database - SQL
to retrieve the data from Ms-access then you create a database , table and create a connection with this. Then you retrieve the data from the database. Thanks
JSP Database Example
This example shows you how to develop JSP that connects to the database and retrieves the data from database. The retrieved data is displayed on the browser. Read Example JSP Database Example Thanks
Database Sql question? - WebSevices
Database Sql question?  Given relation r (a, b,c), show how to use the exstended SQL features to generate a histogram of c versus a, dividing a into 20 equal-sized partions (that is where each partition contains 5 percent
connection with database - JSP-Servlet
with the database by writing the program in java. Following is the code: import... and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp
jsp with database.. - Development process
jsp with database..  Hello i need code for..... I have a car... of that brand should be retrieved from database.i have created a table in database... Thanks  For the above code, create database table named
Advertisements
 

 

 

DMCA.com