具有特殊字符的列注释(Column annotation with special characters)
我将通过兼容JPA的ORM读取MS-ACCESS 97数据库。 重点是数据库中的列名具有特殊字符:
@Column(name="FechPró") Date nextDate;在执行时我得到了这个
Caused by: java.sql.SQLException: Column not found at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849) at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1742)可能我必须做这样的事情
@Column(name=new String("FechPró".getBytes("ISO-8859-1")))但这不会编译。
I'm going to read a MS-ACCESS 97 Database thru a JPA compatible ORM. The point is the column name in the database has special characters:
@Column(name="FechPró") Date nextDate;And at execution I get this
Caused by: java.sql.SQLException: Column not found at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849) at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1742)Probably I have to do something like this
@Column(name=new String("FechPró".getBytes("ISO-8859-1")))But this won't compile.
最满意答案
也许我说的很明显,但是......你试过传递compilier的编码参数吗? 喜欢这篇文章?
也许我再次说明这个选项:如果您使用像eclipse这样的IDE,您可以搜索首选项来为您的项目设置编码。
Maybe I'm stating the obvious but... did you try passing the compilier the encoding parameter? like in this article?
And maybe I'm again stating the option: if you use an IDE like eclipse you can search through the preferences to set up an encoding for your project.
更多推荐
发布评论