Redian新闻
>
jdbc/odbc MS Access file creation question
avatar
jdbc/odbc MS Access file creation question# Java - 爪哇娇娃
c*t
1
Is it possible to create a database file through jdbc/odbc?
In the ODBC data source window, I see
MS Access Database
but, what is the url for creating database? I know that I
could create an empty access database before hand, and put
that file into the User Sources, but that's requires user
configuration, which is bad.
Anyone can help?
BTW, when I get an SQL exception such as
SQLException: [Microsoft][ODBC Microsoft Access Driver] Table 'COFFEES'
already exists.
Is the connection still
avatar
z*g
2
I don't think you could create mdb file from JDBCODBC.
The user has to do this.
If you want to avoid user configuration, use Installshield to create
a install package. Install shiedl could do the data source setup.
And the exception seems caused from you were trying to
crate table "Coffees" which is already existing in the database.

【在 c*****t 的大作中提到】
: Is it possible to create a database file through jdbc/odbc?
: In the ODBC data source window, I see
: MS Access Database
: but, what is the url for creating database? I know that I
: could create an empty access database before hand, and put
: that file into the User Sources, but that's requires user
: configuration, which is bad.
: Anyone can help?
: BTW, when I get an SQL exception such as
: SQLException: [Microsoft][ODBC Microsoft Access Driver] Table 'COFFEES'

avatar
c*t
3
Thanks. I found another way. Create an empty database file and
copy it to the file name I wanted.
The exception was related to the question "should I close the connection"
part.

【在 z****g 的大作中提到】
: I don't think you could create mdb file from JDBCODBC.
: The user has to do this.
: If you want to avoid user configuration, use Installshield to create
: a install package. Install shiedl could do the data source setup.
: And the exception seems caused from you were trying to
: crate table "Coffees" which is already existing in the database.

avatar
z*g
4
Oh, didn't read all through.
Generally, you will do is
Connection conn = null or initialize here.
try{
//sql code...
}
catch(SQLException e)
{
}
finally
{
try{
if(conn!=null)
conn.close();
}
catch(SQLException ee)
{
}
}

【在 c*****t 的大作中提到】
: Thanks. I found another way. Create an empty database file and
: copy it to the file name I wanted.
: The exception was related to the question "should I close the connection"
: part.

avatar
l*r
5
the whole steps:
1. make sure you create some good mdb files somewhere your user account have
permission to read and/or write.
2. make data source name, choose MS Access Driver ==> go to User DSN (only for
local usage) or System DSN (for mapped drives and web server usage) to create
your DSN. supposed the name is "example".
3. then your dsn is "jdbc:odbc:example"
4. use JDBC API, load jdbc driver first, then connnect to DB use
"jdbc:odbc:example", after that you can execute your SQL statements.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。