
没说是什么数据库啊!
不过基本的语言应该差不多!
1)
select Min(DNo) as 部门, sum(salary)/count(eNo) as 高于600的平均工资 from emp
where salsry>=600
group by DNo
2)
update emp
set salary = salary11
where salary<600
and DNO in (select dNo from dept where dName='销售部')
试试吧,我没有调试,如有问题可以发邮件给我,见我的博客:>
import javasql;
public final class DBUtils
{
//1数据库在哪里,叫什么名字(连接串)
private static final String url="数据库连接串/数据库名";
//2用哪个驱动连接数据库(驱动串)
private static final String driver="数据库驱动串";
//通过静态块加载驱动
static
{
try
{
//1加载驱动串
ClassforName(driver); //反射加载,new Driver();
}
catch (ClassNotFoundException e)
{
eprintStackTrace();
}
}
public static Connection getConnection()throws Exception
{
return DriverManagergetConnection(url, "实例名", "密码");
}
public static void close(ResultSet rs)
{
try
{
//语句对象销毁
rsclose();
}
catch(Exception ex)
{
exprintStackTrace();
}
}
public static void close(PreparedStatement pstm)
{
try
{
//语句对象销毁
pstmclose();
}
catch(Exception ex)
{
exprintStackTrace();
}
}
public static void close(Connection conn)
{
try
{
//连接对象销毁
connclose();
}
catch(Exception ex)
{
exprintStackTrace();
}
}
以上就是关于数据库编程全部的内容,包括:数据库编程、请问,数据库与编程的区别和联系。、7、 Java数据库编程包含哪些类Java数据库编程的基本过程是什么等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)