一个表只能有一个主键,如果是联合主键,在表级别定义两个字段有主键约束,这不就是有两个主键了嘛,还是说一个表只能有一个主键A,不能有主键A又有主键B(也就是说主键是一个,但能约束多个字段)?
为社么要在外面定义一个空Connection
不直接在里面定义
老师好,这里用拼接不理解,不是内容才要拼接么,
public class DruidTest { public static void main(String[] args) throws Exception { //获取读取druid配置的字节输入流 InputStream is = DruidTest.class.getClassLoader().getResourceAsStream("druid.properties"); //创建Properties对象 Properties pos = new Properties(); //加载配置文件 pos.load(is); //获取连接池对象 DataSource ds = DruidDataSourceFactory.createDataSource(pos); //获取连接 Connection connection = ds.getConnection(); System.out.println(connection); } }
老师,我这个练习题的11.9为啥显示不出结果呢?job_grades表也在啊
不好意思老师这个V18949999576,麻烦了!
1、老师如果要同时添加两个列check应该怎么添加,比如ID和salary
2、如果salary要求大于5000 小于1000,是这样写吗 check(salary>1000 and salary<5000)吗
老师,为什么我的配置文件目录下面没有my.ini只有一个叫my-default.ini的文件,而且修改好重启服务在运行也不会生效。
老师,我想问一下为什么视频中的这个题目:
如果单独用一个select语句查询部门中的最低薪水可以查出来:
但是为什么当把这个select语句作为子查询语句,添加到另一个select语句中输出的数据就不一样了:
我输出的明明还是那个最低薪水,为什么结果就不一样了
为什么我转化为等值连接后搜素的数量不一样,好像老师在视频中没有选择运行等值连接的那段SQL查询,系统还是进行自然连接的那段SQL查询
老师帮我看一下这个异常信息 package com.bjsxt.dao; import com.bjsxt.common.jdbcUtils; import com.bjsxt.pojo.Users; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class UserLoginDaoImpl implements UserLoginDao { @Override public boolean userLogin(String username, String password) { Connection conn = null; try{ conn = jdbcUtils.getConnection(); PreparedStatement ps = conn.prepareStatement("select * from bookusers where username=? and password=?"); ps.setString(1, username); ps.setString(2, password); ResultSet resultSet = ps.executeQuery(); if(resultSet.next()){ return true; } } catch (Exception e) { e.printStackTrace(); } finally { jdbcUtils.closeConnection(conn); } return false; } public static void main(String[] args) { UserLoginDaoImpl userLoginDaoImpl = new UserLoginDaoImpl(); boolean b = userLoginDaoImpl.userLogin("憨憨崽", "hanhanzai"); System.out.println(b); } } jdbc工具类: package com.bjsxt.common; import javax.annotation.Resource; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.ResourceBundle; public class jdbcUtils { private static String driver; private static String url; private static String username; private static String password; static{ try{ ResourceBundle bundle = ResourceBundle.getBundle("db"); driver = bundle.getString("jdbc.driver"); url = bundle.getString("jdbc.url"); username = bundle.getString("jdbc.username"); password = bundle.getString("jdbc.password"); Class.forName(driver); } catch(ClassNotFoundException e) { e.printStackTrace(); } } //获取连接方法 public static Connection getConnection(){ Connection conn = null; try{ conn = DriverManager.getConnection(url,username,password); } catch (Exception e) { e.printStackTrace(); } return conn; } public static void closeConnection(Connection conn) { try{ conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } 异常信息: Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.bjsxt.common.jdbcUtils at com.bjsxt.dao.UserLoginDaoImpl.userLogin(UserLoginDaoImpl.java:26) at com.bjsxt.dao.UserLoginDaoImpl.main(UserLoginDaoImpl.java:33)
按照视频步骤操作完点apply弹出这个报错
这种号码有多个重复的,它值替换靠前的,这个怎么解决?
老师这一题数量这么打,是因为部门ID相等时,每个部门的人都找了一遍自己的同事吧?就除了自己了!
老师,这个是报错是因为什么呢?没有ngram插件吗
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637