incompatible types; found: java.sql.Connection, required: com.redv.database.Connection at line
redv 2002-12-31 01:37:12 package com.redv.database;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: Redv.com</p>
* @author webmaster@redv.com
* @version 1.0
*/
import java.sql.*;
import java.io.*;
import java.util.*;
public class Connection
{
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
public Connection()
{
}
public boolean open()
{
Properties prop = new Properties();
try
{
InputStream is = getClass().getResourceAsStream("db.ini");
prop.load(is);
if(is != null) is.close();
}
catch(IOException e)
{
System.out.println("[DbConnection] Open db.txt File, Error!");
}
String driver = prop.getProperty("driver");
String url = prop.getProperty("url");
String user = prop.getProperty("user");
String password = prop.getProperty("password");
//System.out.println("jdbc=[" + jdbc + "]");
//System.out.println("uri=[" + uri + "]");
try
{
Class.forName(driver).newInstance();
}
catch(ClassNotFoundException e)
{
System.out.println("JDBC login, Error!@" + e.getMessage());
return false;
}
catch (Exception e)
{
System.err.println("Unable to load driver!");
e.printStackTrace();
}
try
{
this.connection = DriverManager.getConnection(url,user,password);//它说这里有语法错误:"Connection.java": Error #: 354 : incompatible types; found: java.sql.Connection, required: com.redv.database.Connection at line 65, column 52
}
catch(SQLException e)
{
System.out.println("Generate Connection, Error!" + e.getMessage());
return false;
}
return true;
}
public void close() throws SQLException
{
if(connection != null) connection.close();
if(resultSet != null) resultSet.close();
if(statement != null) statement.close();
}
public static void main(String []args)
{/*
com.redv.database.DatabaseConnection db = new com.redv.database.DatabaseConnection();
if(db.open())System.out.println("Database opened.");
try
{
db.close();
System.out.println("Database closed.");
}
catch(SQLException e)
{
}*/
}
}
请问这是这么回事?