java连接oracle数据库的问题
我的oracle http和数据库服务都开着的
出错:Io 异常: The Network Adapter could not establish the connection
是怎么回事
//////////////////////////////////
import java.sql.*;
public class OracleTest {
private final String oracleDriverName = "oracle.jdbc.driver.OracleDriver ";
//以下使用的Test就是Oracle里的表空间
private final String oracleUrlToConnect = "jdbc:oracle:thin:@localhost:1521:test ";
private Connection myConnection = null;
/**
* To load the jdbc driver
*
*/
public OracleTest()
{
try
{
Class.forName(oracleDriverName);
}catch(
ClassNotFoundException ex)
{
System.out.println(getErrorMessage(ex, "The Driver loaded error,please contact to your Software Designer! ").toString());
}
}
public StringBuffer getErrorMessage(Exception ex,String alarmMessage)
{
StringBuffer errorStringBuffer = new StringBuffer();
errorStringBuffer.append(alarmMessage);
errorStringBuffer.append(ex.getMessage());
return errorStringBuffer;
}
/**
* getConnection method
* @return Connection
*/
public Connection getConnection()
{
try
{
this.myConnection = DriverManager.getConnection(oracleUrlToConnect, "sys ", "admin ");
}catch(Exception ex)
{
System.out.println(getErrorMessage(ex, "Can not get connection,please contact to your Software Designer!\n ").toString());
}
return this.myConnection;
}
/**
* @param args
*/
public static void main(String[] args) {
OracleTest myOracleTest = new OracleTest();
try
{