c*****t 发帖数: 1879 | 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 | z****g 发帖数: 2497 | 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'
| c*****t 发帖数: 1879 | 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.
| z****g 发帖数: 2497 | 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.
| l******r 发帖数: 99 | 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. |
|