java当中请给出一个oracle的helloworld例子
[学习笔记]
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例子的更多相关文章
- java中JDBC当中请给出一个DataSource的HelloWorld例子
在前面 的jdbc的Helloworld程序当中,我们用DriverManager来获取数据库连接.事实上通过这种方法获取数据库连接,是比较耗费计算机资 源的.当然了,这也是没有办法的事儿.就像我们买 ...
- java当中JDBC当中请给出一个Oracle DataSource and SingleTon例子
[学习笔记] 6.Oracle DataSource and SingleTon: import oracle.jdbc.pool.OracleDataSource;import java.sql.C ...
- java中请给出一个return this的例子。
[新手可忽略不影响继续学习]下面例子中setYear中的return this;返回了一个指向对象的指针,this.setMonth(8).setDay(20);是合法的,如果像原来的例子一样什么都不 ...
- java当中JDBC当中请给出一个sql server的helloworld例子
[学习笔记] 1.sql server的helloworld例子: import java.sql.*; public class JdbcHelloSqlServer { public stati ...
- java当中JDBC当中请给出一个DataSource的单态模式(SingleTon)HelloWorld例子
[学习笔记] 2.DataSource的单态模式(SingleTon)程序 咱们还接着上面的例子来说.1万个人要看书.千万确保要只建立一个图书馆.要是一不留神,建了两个或三个图书馆,那可就亏大发了.对 ...
- java当中JDBC当中请给出一个sql server的stored procedure例子
3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...
- java当中JDBC当中请给出一个sql server的dataSource的helloworld例子
[学习笔记] 4. sql server的dataSource的helloworld: import java.sql.*;import javax.sql.*;import net.sourcef ...
- java当中JDBC当中请给出一个SQLServer DataSource and SingleTon例子
[学习笔记] 5.SQLServer DataSource and SingleTon: import net.sourceforge.jtds.jdbcx.*;import java.sql.*;i ...
- java中请给出一个抽象类,可以继承实体类的例子
例1.7.2(抽象类可以继承实体类)- class VehMark_to_win { void steer() { System.out.println("Turn st ...
随机推荐
- HDU 6194 string string string ——(2017沈阳网络赛,后缀数组)
思路见:http://blog.csdn.net/aozil_yang/article/details/77929216. 代码如下: #include <stdio.h> #includ ...
- Java ArrayList几种遍历方法
import java.util.ArrayList; import java.util.Iterator; public class StringSampleDemo { public static ...
- Tkinter 之记事本项目实战
一.效果图 二.文件 链接:https://pan.baidu.com/s/1CUkfWpfH8t2GSJyy5hYv-A 提取码:5yvn 后续可能做一些功能扩展,有需要源码的可以评论联系我!!!
- 用vue做的购物车结算的功能
<!-- 占位 --> <template> <div> <div class="product_table"> <div c ...
- MongoDB允许其它IP地址访问
网址:https://blog.csdn.net/sl1992/article/details/83964310 文章目录1.允许所有地址访问2.绑定内网IP3.绑定多个IP Linux服务器上安装M ...
- VOT-2016 代码评测工具的使用说明
VOT-2016 代码评测工具的使用说明 2018-10-14 09:37:04 VOT-2016 官网:http://www.votchallenge.net/vot2016/ 评测代码链接:htt ...
- git只提交修改部分的代码
思路: 先用git status 查找出哪些文件被修改过了,然后 只git commit odin/code/pom.xml 1. $ git status (查看当前更改的代码) On branch ...
- CentOS上安装GlassFish4.0
1. 安装jdk 2. 下载并安装glassfish4 [root@linuxidc ~]# mv glassfish-4.0-ml.zip /usr/share/glassfish-4.0-ml. ...
- Visual Studio 2019更新到16.2.2
Visual Studio 2019更新到16.2.2 此次更新的变化有以下几点: (1)修复了Visual Studio在关闭时的停止响应问题.(2)修复CVE-2019-1211权限提升漏洞.(3 ...
- Spring cloud微服务安全实战-5-4请求转发及退出
步骤1234已经完成 下面处理 5678这几步.zuul在转发的时候 把请求头加上 获取订单信息 加一个按钮,登陆成功后,去拿订单的信息. 展示获取到的订单信息 ts代码 ts内定义order对象 定 ...