zoukankan      html  css  js  c++  java
  • oracle,sqlserver,mysql常见数据库jdbc连接

    发现JDBC连接字符串总是容易忘记,特此整理一下常用的几种数据的连接

    ORACLE

      /**
         * ORACLE
         * */
        public static Connection getOracleConnection(){
            Connection connection = null;
            try {
                Class.forName("oracle.jdbc.OracleDriver");
                connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "username", "password");
            } catch (Exception e) {
                // TODO 自动生成的 catch 块
                e.printStackTrace();
            }
            return connection;
        }
    

    SQLSERVER

        /**
         * SQLSERVER
         * */
        public static Connection getSqlServerConnection(){
            Connection connection = null;
            try {
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                connection = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test", "username", "password");
            } catch (Exception e) {
                // TODO 自动生成的 catch 块
                e.printStackTrace();
            }
            return connection;
        }
    

    MYSQL

        /**
         * MYSQL
         * */
        public static Connection getMySqlConnection(){
            Connection connection = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test", "username", "password");
            } catch (Exception e) {
                // TODO 自动生成的 catch 块
                e.printStackTrace();
            }
            return connection;
        }
  • 相关阅读:
    转载:Cgroups 与 Systemd
    转载:linux cgroups 简介
    深入剖析Linux IO原理
    Tomcat zabbix监控、jmx监控、zabbix_java_gateway
    Tomcat 打开jmx
    vsftp、ftps 搭建
    Tomcat 调优
    Tomcat 部署及配置
    SVN 搭建
    Nginx 编译安装
  • 原文地址:https://www.cnblogs.com/gavinYang/p/3515890.html
Copyright © 2011-2022 走看看