使用JDBC连接Oracle数据库:出现java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection 是什么意思
这是我连接代码;
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%--
使用myoracle数据库
用户名:scott
密码:tiger
--%>
<%!
String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;
String DBURL = "jdbc:oracle:thin:@localhost:1521:myoracle" ;
String DBUSER = "scott" ;
String DBPASSWORD = "tiger" ;
Connection conn = null ;
Statement stmt = null ;
%>
<%
try
{
Class.forName(DBDRIVER) ;
// 连接时必须填写用户名及密码
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD) ;
// 创建表的SQL语句
String sql = "CREATE TABLE mldntab (name varchar(20))" ;
stmt = conn.createStatement() ;
stmt.executeUpdate(sql) ;
stmt.close() ;
conn.close() ;
}
catch(Exception e)
{
out.println(e) ;
}
%>