[学习笔记]

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. spaceclaim脚本(内摆线)

    import math #导入数学模块,因为会使用π def x_comp(k,r,t): #定义x坐标的计算函数 return r * (k -1) * math.cos(t) + r * math ...

  2. Rare-Variant Association Analysis | 罕见变异的关联分析

    Rare-Variant Association Analysis: Study Designs and Statistical Tests 10 Years of GWAS Discovery: B ...

  3. Maven Multi-Module Example

    Maven Multi-Module - 国内版 Binghttps://cn.bing.com/search?q=Maven+Multi-Module&qs=n&form=QBRE& ...

  4. c++ 标准 字符串转换为时间 时间大小比较 判断有效期 简洁办法

    c# php delphi java 等各种语言 对字符串转换为日期 然后与当前日期进行比较 是非常容易的 因为有现成的函数可用 标准 c++ 硬是找不到 合适的代码可用 于是 百度了很多 没百出个结 ...

  5. iptables 配置 场景1

    这样配置完成后,没法完成本地回环,需要对lo网卡进行配置 本地报文无法发出,继续添加规则

  6. 让remix使用本地文件系统

    让remix使用本地文件系统   转:https://blog.csdn.net/platocnet/article/details/83376792 1. 测试发现使用npm命令安装相关环境不成功, ...

  7. typeScript模块<四>

    /* 功能:定义一个操作数据库的库 支持 Mysql Mssql MongoDb 要求1:Mysql MsSql MongoDb功能一样 都有 add update delete get方法 注意:约 ...

  8. Spring cloud微服务安全实战-4-2微服务安全的新挑战

    微服务的环境下,我的业务逻辑不再是在一个单一的进程里,而是分散了很多的进程里.订单.物流.库存.价格.每一个tomcat都是一个进程. 每一个进程,每一个tomcat都有自己的入口点.那么就导致我防范 ...

  9. 转 ORA-16191 "Primary log shipping client not logged on standby

    ###sample 0 原因未知: 解决办法,重建密码文件 primary db :alter system set log_archive_dest_state_2=defer sid='*' sc ...

  10. 123457123457#0#-----com.tym.PuzzleGame28--前拼后广--日常pt-tym

    com.tym.PuzzleGame28--前拼后广--日常pt-tym