Skip to main content

MYSQL JDBC Connectivity Example

1. create a table in mysql name contact with
columns name,mobile,email,password
2.open bluej add reference library mysql-connector-java-5.1.13-  bin.jar file if not available download from internet.
3.type the code given below. compile it and execute. Success.



import java.sql.DriverManager;
import com.mysql.jdbc.Driver;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
public class test
{
    public static void main(String args[])
    {
        String Name="SHIV SINGH";
        String Mobile="9929760942";
        String Email="
s@gmail.com";
        try       
        {
        Class.forName("java.sql.DriverManager");
        Connection con = (Connection)
        DriverManager.getConnection
        ("jdbc:mysql://localhost:3306/dbname","root", "dbpassword");
        Statement stmt = (Statement) con.createStatement();
        String query="INSERT INTO Contact VALUES('"+Name+"','"+Mobile+"','"+Email+"',password('abc'));";
        stmt.executeUpdate(query);
        System.out.println("Success");
        }
        catch(Exception e)
        //this block is executed in case of an exception
        {
        //Display an error message in the dialog box for an exception
        System.out.println(e.getMessage());
        }
    }
}

Comments

Popular posts from this blog

Web Designer

If you want to be a web designer. Skills Should have worked on and have a good understanding of the following packages and areas: HTML Javascript / VBscript JSP ASP Photoshop Flash Dream Weaver Frontpage Should have aesthetic picture and designing abilities (including usage of color combinations, CSS files, etc). Should have the ability to understand client requirements; and translate into appropriate web interface. Should be comfortable in working with Windows/ Java environment Work Experience At least 2 to 3 years of good web designing experience Web pages should be bug free and clean/ simple and light Should have managed/ maintained websites that are currently hosted and running Key Responsibilities Testing and implementation Analysis and design of solutions at both onsite and client sites to integrate the company's product Interaction with clients to implement solutions Interaction with third party solution providers for project i...

Multimedia and Web Technology (Code 067)

Multimedia and Web Technology (Code 067) Learning Objectives: 1. To get proficient in WEB Development using HTML/XML 2. To be able to write server & client scripts. 3. To get proficient in Web Management 4. To get proficient in creating Web Site 5. To design Graphical images using Image-Editing tools 6. To get proficient in audio & video capture and editing using software tools 7. To create and publish a self-contained multimedia CD-ROM using multimedia authoring tool 8. To develop ability to use the Open Source Technology. 9. To develop ability to localize software applications. Competencies: The student will become proficient in the following: 1. Managing Self Developed web-site 2. Management of a full-fledged web portal 3. Creation & Editing of graphical images. 4. Capturing, Creating and Editing Audio and Video through external devices. 5. Embedding images & video into a presentation. Class XI (Theory) Duration: 3 hours Total Marks: 70 Unit No. ...

CSS Properties

margin : length or percentage or auto;   margin-top a:link list-style margin-left a:visited list-style-image margin-right a:hover list-style-image-position margin-bottom a:focus list-style-image-type padding-top : length or percentage Css Anchor, Link height padding-left a.column1:link line-height padding-right Css Border max-height padding-bottom border min-height color : red or #2398 or rgb(,,) border-style max-width letter-spacing : normal or length border-width min-width text-align: left or center or right or justify border-bottom Css Classification text-decoration: underline or overline or line through or blink border-bottom-color clear text-indent : length or percentage border-bottom-style cursor text-transform: none or capitalize or lowercase border-bottom-width display white-space: normal or pre or nowrap bord...