首页 \ 问答 \ 连接表的Rails命名约定(Rails naming convention for join table)

连接表的Rails命名约定(Rails naming convention for join table)

这个问题源于: 如何在创建rails连接表之后链接表单

我正在创建我的产品和类别模型之间的连接表。

应该怎样命名连接表? categories_products或category_products或其他东西?


This questions stems from: How to link form after creating rails join table

I am creating the join table between my Product and Category Models.

What should the join table be named? categories_products or category_products or something else?


原文:https://stackoverflow.com/questions/11590469
更新时间:2022-09-04 07:09

最满意答案

参考下:
public class DBConnection {
    private static final String DBDRIVER = "com.mysql.jdbc.Driver"; // 驱动类类名
    private static final String DBURL = "jdbc:mysql://127.0.0.1:3306/test";// 连接URL
    private static final String DBUSER = "root"; // 数据库用户名
    private static final String DBPASSWORD = "123"; // 数据库密码
    public static Connection getConnection() {
Connection conn = null;
try {
    Class.forName(DBDRIVER).newInstance(); // 注册驱动
    conn = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD); // 获得连接对象
} catch (Exception e) {
    e.printStackTrace();
}
return conn;
    }
}

其他回答

你试试把驱动的jar包导入到工程里面试试。。这个错误显示的是你的驱动包没有找到。你直接导入到工程就可以找到了
是用JDBC做的?
是web项目吗   把jar包放到项目路径下的web-inf下的lib文件夹下啊
总之就是跟你项目的其它包放一起啊

相关问答

更多
  • 下载个 mysql-connector-java-XXX-bin.jar,XXX处为版本号 并放到你Java项目的 WEB-INF/lib 下 然后采用 jdbc:mysql://localhost:3306/DB 方式连接
  • 是这样的,首先你会发现这句话会抛出一个异常ClassNotFoundException(无法找到驱动类)驱动是在程序第一次运行的时候进行加载,如果你是发布到服务器上并且加载后运行了一遍,那么第二次注视了确实没有什么问题。这是你的第一个问题。第二个来说就是首先你需要定义好一个针对于数据库的连接,这个连接如果被你的程序调用那么就可以用来访问数据库,其中的字符串第一个就是你定义的连接名称(连接服务名称),第二个是你的数据库登陆名称,第三个就是对应的密码。
  • 区别是你导了三个不同的jar包,创建数据库连接驱动,javaJDK并没有提供完整的实现,但是支持组建的实现,所有就有了好多不同机构对他做了具体的实现,需要导入一个driver包,后缀为.jar。你导不同的jar包,jar包定义的路径都不同,他们之间没有实质的差别。一般来讲我们都是用的第二个,据说是因为稳定。
  • 你用mysql-connector-java-3.XX-bin.jar的驱动,你要放在WEB-INF\LIB里,没有我发给你,5的也有。
  • 参考下: public class DBConnection { private static final String DBDRIVER = "com.mysql.jdbc.Driver"; // 驱动类类名 private static final String DBURL = "jdbc:mysql://127.0.0.1:3306/test";// 连接URL private static final String DBUSER = "root"; // 数据库用户名 private static ...
  • https://wenwen.sogou.com/login/redirect?url=http%3A%2F%2Fdev.mysql.com%2Fget%2FDownloads%2FConnector-J%2Fmysql-connector-java-5.1.6.tar.gz%2Ffrom%2Fpick%3Ffile%3DDownloads%2FConnector-J%2Fmysql-connector-java-5.1.6.tar.gz%26amp%3Bmirror%3Dpick%26amp%3Bfile ...
  • 如果你用的是intellij,请打开菜单栏File => Project Structrue => Artifacts => 选中[你的工程名]:war exploded =>右边依次展开 => WEB-INF => lib 看里面有没有你的mysql驱动包,如果没有,请点击上面的+号 => Library Files 然后选上你的mysql驱动包 当然,我说的是可能bug,并不是为了回答楼主的问题,而是让使用intellij的朋友进来能看到一种可能的错误原因,如果不能解决你的问题,请见谅
  • http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.6.tar.gz/from/pick?file=Downloads/Connector-J/mysql-connector-java-5.1.6.tar.gz&mirror=pick&file=Downloads/Connector-J/mysql-connector-java-5.1.6.tar.gz&mirror=pick&file=Downloads/Conn ...
  • 参考下: public class DBConnection { private static final String DBDRIVER = "com.mysql.jdbc.Driver"; // 驱动类类名 private static final String DBURL = "jdbc:mysql://127.0.0.1:3306/test";// 连接URL private static final String DBUSER = "root"; // 数据库用户名 private static ...
  • MySQL: MySQL.Driver =com.mysql.jdbc.Driver MySQL.URL =jdbc:mysql://localhost:3306/myDB?autoReconnect=true MySQL.User =xxxx MySQL.Password =xxxx mysql jar 包需要去mysql 网站去下载

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)