Six popular language dinners: Simple presentation of C, C + +, Python, Java, PHP, and C #

Source: Internet
Author: User
Tags mysql mysql database

Introduction

In view of the 51 period of huge flow of people, LZ reasoning, eventually chose to dwelling in their own rental housing. Boredom, of course, can not forget to do something, so LZ on the study of several languages of the fur, here shortcoming a turn, I hope you ape friends mo to laugh.

But it is also a coincidence, the garden before a period of time just staged a language war, which let the LZ of this Boven birth may be involved in unnecessary disputes. In fact, LZ wanted to write such an article, but the language of inquiry is more trouble, because each language is often the most difficult to do is the environment, and very waste of time, so LZ picked 51 this opportunity to start to proceed.

Anyway, LZ still want to clarify, this article is only the LZ learning results show, resolutely do not participate in the language war. If the ape friends must ask LZ to the language view, LZ can only tell you a LZ to see the fantasy novel.

This novel tells the world of a magician and samurai, each person is born, the body will have "Jin Mu Fire and Fire" one of the characteristics of these attributes, some days longitudinal wizards will have a variety of attributes. We all go from one level to nine floors and 10 layers to become gods. In this system of cultivation, there is a special but very reasonable setting, that is, before becoming a God, we will learn from the air each of the corresponding attributes of the elements of cultivation, in order to understand the heaven. But after realizing that heaven became God, the attributes of the person who became God disappeared, and even the samurai and the Sorcerer were no different. For the man who became a god, all that was left of them was the supremacy of the divine power. No attribute, no occupation.

Well, the story is here, do not know the ape friends understand it?

Language feast

Back to the point, this article is six languages to connect the MySQL database code display, in the LZ trial process, whether it is the language environment, MySQL dependent library import or code style, various languages are different. Next, let's let these languages go.

Java (most gimmick language)

Java to the new impression should be a simple introduction, code elegance, high activity, cross-platform, open source family and so on, it is a well-deserved star language, but also idol pie. But unfortunately, Idol stars are easy to get rid of. The Java language is the LZ relies on the language, so LZ do not want to be an idol pie, can only catch up and strive to do the Javaer.

Speaking of this Java connection MySQL writing, there is nothing to say, after all, it is to do this, so this way very smooth, is the least sense of one. The following is the LZ-written code.

Package cn.zxl.jmysql;  
Import java.sql.Connection;  
Import Java.sql.DriverManager;  
Import Java.sql.ResultSet;  
      
Import java.sql.Statement;  
    public class Jmysql {private static final String DRIVER = "Com.mysql.jdbc.Driver";  
    private static final String URL = "Jdbc:mysql://localhost/test";  
    private static final String USERNAME = "root";  
    private static final String PASSWORD = "123456";  
          
    private static final String SQL = "SELECT * from Test";  
        public static void Main (string[] args) {Connection Connection = null;  
        Statement Statement = null;  
        ResultSet ResultSet = null;  
            try {class.forname (DRIVER);  
            Connection = Drivermanager.getconnection (URL, USERNAME, PASSWORD);  
            statement = Connection.createstatement ();  
            ResultSet = Statement.executequery (SQL); while (Resultset.next ()) {System.out.printlN ("|" + resultset.getstring ("id") + "|" + resultset.getstring ("name") + "|");  
        The catch (Exception e) {System.out.println ("Query failed!");  
                Finally {try {resultset.close ();  
                Statement.close ();  
            Connection.close ();  
            catch (Exception e) {throw new RuntimeException (e); }  
        }  
    }  
          
}

The following is the output, indicating that the program is correct.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.