[学习笔记]

2.oracle的helloworld例子:

import java.sql.*;
public class OracleHello{
    public static void main(String args[]) {
        Connection con;
        String createString;
        createString = "select EMPNO from EMP";
        Statement stmt;
        try {
/*see above, import sun.jdbc.odbc.JdbcOdbcDriver;*/
/*see above, import sun.jdbc.odbc.JdbcOdbcDriver;for kkk this kind of url connection string, you must
            use sun.jdbc.odbc.JdbcOdbcDriver. if you wan to use oracle.jdbc.driver.OracleDriver, you must use
            jdbc:oracle:thin:@localhost:1521:qixy */
/*a sound blaster hardware need a driver to function, software draw awave, then when play,
through the driver, hardware can change it to sound you can hear. here your statement can
be sent to the database.

public static Class forName(String className)
                      throws ClassNotFoundExceptionReturns the Class object associated with the class or interface with the given string name. Invoking this method is equivalent to:
   Class.forName(className, true, currentLoader)
  where currentLoader denotes the defining class loader of the current class.
 For example, the following code fragment returns the runtime Class descriptor for the class named java.lang.Thread:

Class t = Class.forName("java.lang.Thread")
  A call to forName("X") causes the class named X to be initialized.

*/
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:qixy", "scott", "tiger");
            System.out.println("Connection is ok");
            stmt = con.createStatement();
  //          stmt.execute(createString);
            ResultSet rs=stmt.executeQuery(createString);
            while(rs.next())
            {     String no=rs.getString("EMPNO");
                  System.out.println(no);
            }
            stmt.close();
            con.close();        }
        catch (Exception ex) {
            ex.printStackTrace();
        }    }}

文章转载自原文:https://blog.csdn.net/qq_44594249/article/details/100669095

java当中请给出一个oracle的helloworld例子的更多相关文章

  1. java中JDBC当中请给出一个DataSource的HelloWorld例子

    在前面 的jdbc的Helloworld程序当中,我们用DriverManager来获取数据库连接.事实上通过这种方法获取数据库连接,是比较耗费计算机资 源的.当然了,这也是没有办法的事儿.就像我们买 ...

  2. java当中JDBC当中请给出一个Oracle DataSource and SingleTon例子

    [学习笔记] 6.Oracle DataSource and SingleTon: import oracle.jdbc.pool.OracleDataSource;import java.sql.C ...

  3. java中请给出一个return this的例子。

    [新手可忽略不影响继续学习]下面例子中setYear中的return this;返回了一个指向对象的指针,this.setMonth(8).setDay(20);是合法的,如果像原来的例子一样什么都不 ...

  4. java当中JDBC当中请给出一个sql server的helloworld例子

    [学习笔记] 1.sql server的helloworld例子: import java.sql.*; public class JdbcHelloSqlServer {  public stati ...

  5. java当中JDBC当中请给出一个DataSource的单态模式(SingleTon)HelloWorld例子

    [学习笔记] 2.DataSource的单态模式(SingleTon)程序 咱们还接着上面的例子来说.1万个人要看书.千万确保要只建立一个图书馆.要是一不留神,建了两个或三个图书馆,那可就亏大发了.对 ...

  6. java当中JDBC当中请给出一个sql server的stored procedure例子

    3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...

  7. java当中JDBC当中请给出一个sql server的dataSource的helloworld例子

     [学习笔记] 4. sql server的dataSource的helloworld: import java.sql.*;import javax.sql.*;import net.sourcef ...

  8. java当中JDBC当中请给出一个SQLServer DataSource and SingleTon例子

    [学习笔记] 5.SQLServer DataSource and SingleTon: import net.sourceforge.jtds.jdbcx.*;import java.sql.*;i ...

  9. java中请给出一个抽象类,可以继承实体类的例子

    例1.7.2(抽象类可以继承实体类)- class VehMark_to_win {    void steer() {        System.out.println("Turn st ...

随机推荐

  1. Tkinter 之磁盘搜索工具实战

    一.效果图 二.代码 miniSearch.py from tkinter import * from tkinter import ttk, messagebox, filedialog from ...

  2. Nginx介绍和使用

    Nginx介绍和使用 一.介绍 Nginx是一个十分轻量级并且高性能HTTP和反向代理服务器,同样也是一个IMAP/POP3/SMTP代理服务器. 二.特性 HTTP服务器 反向代理服务器 简单的负载 ...

  3. python window窗口

    from Tkinter import * root=Tk() root.title('我是root窗口!') L=Label(root,text='我属于root') L.pack() f=Topl ...

  4. What are all the possible values for HTTP “Content-Type” header?

    What are all the possible values for HTTP “Content-Type” header? You can find every content type her ...

  5. 关于 array of const

    之前应该参考一下: 关于开放数组参数 //这是在 System 单元定义的一组标识数据类型的常量: vtInteger    = ; vtBoolean    = ; vtChar      = ; ...

  6. useState 的介绍和多状态声明(二)

    useState的介绍 useState是react自带的一个hook函数,它的作用是用来声明状态变量. 那我们从三个方面来看useState的用法,分别是声明.读取.使用(修改).这三个方面掌握了, ...

  7. python PIL/cv2/base64相互转换

    PIL和cv2是python中两个常用的图像处理库,PIL一般是anaconda自带的,cv2是opencv的python版本.base64在网络传输图片的时候经常用到. ##PIL读取.保存图片方法 ...

  8. SQLServer系统视图sysobjects中type字段说明

    SQLServer中系统视图sysobjects中type字段的对象类型: AF = 聚合函数 (CLR) C = CHECK 约束 D = DEFAULT(约束或独立) F = FOREIGN KE ...

  9. Kotlin从零到精通Android开发

    作者 博客地址 https://blog.csdn.net/aqi00 最新源代码 https://github.com/aqi00/kotlin 资源下载和内容勘误  https://blog.cs ...

  10. flutter 日志工具类

    class LogUtils { //dart.vm.product 环境标识位 Release为true debug 为false static const bool isRelease = con ...