在写action的时候引入自己写的一个类函数,但是运行时提示错误Only a type can be imported.
类函数内容如下
package org.crazyit.hrsystem.dao;
import java.sql.*;
import java.util.Hashtable;
import java.util.List;
public class uploadDAOImpl {
static Connection conn;
static Statement st;
//?insert,update,query,delete
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost/etest_db";
conn = DriverManager.getConnection(
url, "root", "sa");
System.out.println("success!");
} catch (Exception e) {
System.out.println("
连接失败" + e.getMessage());
}
return conn;
}
public void insert(String sql){
conn=getConnection();
int count=0;
Statement stmt=null;
try{
stmt=conn.createStatement();
count=stmt.executeUpdate(sql);
System.out.println("插入 " + count + " 条数据");
conn.close();
}catch(Exception e){
System.out.println("插入数据失败"+e.getMessage()+";sql="+sql);
}
}
public static void update() {
conn = getConnection();
try {
String sql = "update resource set wage='23000' where name = 'Tom1'";
st = (Statement) conn.createStatement();
int count = st.executeUpdate(sql);