Statement stat
Connection con = null
//private String strConnect ="jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb, *.accdb)DBQ=E:\\sql\\ffxx.accdb"
//类
public Mdbda() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb, *.accdb)DBQ=E://sql//jxjyExam.accdb"
con = DriverManager.getConnection(url)
stat = con.createStatement()
} catch (ClassNotFoundException ex) {
System.out.println("加载驱动失败")
} catch (SQLException ex) {
Logger.getLogger(Mdbda.class.getName()).log(Level.SEVERE, null, ex)
}
}
public List getOtherDa(String where) {
List list = new ArrayList()
try {
String action = "select * from exam " + where
ResultSet rs = null
rs = stat.executeQuery(action)
while (rs.next()) {
String content=rs.getString("content")
list.add(content)
// System.out.println(content)
}
rs.close()
stat.close()
con.close()
} catch (SQLException ex) {
Logger.getLogger(Mdbda.class.getName()).log(Level.SEVERE, null, ex)
}
return list
}
}
其他类中直接调用 new Mdbda().getOtherDa()就可以获取。
以上是access
#include <stdio.h>void Stat( double a[], int iArrLen)
void main()
{
double a[10]
char ch
int i = 0
//输入十名学生成绩
for ( i =0i <10i++ )
{
scanf( "%lf", &a[i])
}
Stat( a, 10)
printf( "Press any key to exit...")
scanf( "%c", &ch)
}
void Stat( double a[] , int iArrLen )
{
if ( iArrLen <=0 )
{
return
}
double dAvgScore = 0, dTotalScore = 0//声明平均成绩dAvgScore 和总成绩变量dTotalScore
double dMaxScore = 0, dMinScore = 100//声明最高成绩dMaxScore 和最低成绩变量 dMinScore
int cExcellent = 0, cGood = 0, cPass= 0, cFail = 0 //声明
int i = 0
for ( i=0i <iArrLeni++ )
{
dTotalScore += a[i]//计算总成绩
if ( a[i] >dMaxScore )
{
dMaxScore =a[i]
}
if ( a[i] <dMinScore )
{
dMinScore = a[i]
}
if ( a[i] >84 )
{
++cExcellent
}
else
{
if ( a[i] >= 70 &&a[i] <= 84 )
{
++cGood
}
else
{
if ( a[i] >= 60 )
{
++cPass
}
}
}
}
cFail = iArrLen - cExcellent - cGood - cPass//不及格人数为总人数减去其它人数之和
dAvgScore = dTotalScore / iArrLen//计算平均成绩
printf( " 总成绩: %6.2f\n", dTotalScore )
printf( "平均成绩: %6.2f\n", dAvgScore )
printf( " 最高分: %6.2f\n", dMaxScore )
printf( " 最低分: %6.2f\n", dMinScore )
printf( "\n\n")
printf( "84分以上的: %d名学员\n", cExcellent )
printf( " 70-84分的: %d名学员\n", cGood )
printf( " 60-69分的: %d名学员\n", cPass )
printf( "60分以下的: %d名学员\n", cFail )
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)