제목에 명시된 바와 같이 일부 리소스를 찾을 수 있습니까? 아니면 J2EE 프로그램을 액세스 데이터베이스에 연결하는 데 사용해야하는 코드가 있습니까?J2EE 프로그램을 Access 데이터베이스에 연결하는 방법은 무엇입니까?
감사합니다. 당신은 당신이 너무 J2EE를 사용하여 연결 할 수 J2SE를 사용하여 액세스, 데이타베이스를 연결할 수 있으면
제목에 명시된 바와 같이 일부 리소스를 찾을 수 있습니까? 아니면 J2EE 프로그램을 액세스 데이터베이스에 연결하는 데 사용해야하는 코드가 있습니까?J2EE 프로그램을 Access 데이터베이스에 연결하는 방법은 무엇입니까?
감사합니다. 당신은 당신이 너무 J2EE를 사용하여 연결 할 수 J2SE를 사용하여 액세스, 데이타베이스를 연결할 수 있으면
은 (코드로이 부분에 대한 정확히 동일합니다.)
당신은 이러한 스레드에서 코드의 아이디어를 얻을 수 있습니다. 여기 Java not connecting to MS Access database using Eclipse
How to connect to Access .mdb database from 64-bit Java?
http://www.codeproject.com/Articles/35018/Access-MS-Access-Databases-from-Java
또는 http://www.herongyang.com/JDBC/JDBC-ODBC-MS-Access-Connection.html
및 @Marc Estadillo으로
드라이버를 잊지 마세요 말했다 줄입니다.
Connection connection = null;
Statement stmt = null;
ResultSet rs = null;
String mySql = "SELECT ..."; // Put your query here.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try
{
// Arguments 2 and 3 are name and password if required
connection = DriverManager.getConnection("jdbc:odbc:myDriver", "", "");
stmt = connection.createStatement();
rs = stmt.executeQuery(mySql);
while (rs.next()) {
// do stuff with ResultSet
}
}
catch (SQLException sqle)
{
...
}
catch (Exception e)
{
...
}
finally
{
if (null != rs)
{
try
{
rs.close();
}
catch (Exception e)
{
...
}
finally
{
rs = null;
}
}
if (null != stmt)
{
try
{
stmt.close();
}
catch (Exception e)
{
...
}
finally
{
rs = null;
}
}
if (null != connection)
{
try
{
connection.close();
}
catch (Exception e)
{
...
}
finally
{
rs = null;
}
}
}
이 코드가 질문에 올바르게 대답하는 방법을 설명 할 수 있습니다. – rfornal