我尝试了以下方法:
private String password = "";
private String dbName = "dataHC.accdb";
private String bd = dbName + ";PWD=" + password;
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+bd+";";
private Connection conn = null;
//Connect
public void connect() {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url);
if (conn != null)
System.out.println("Conexión a base de datos "+dbName+". listo");
}catch(SQLException e){
System.out.println(e);
}catch(ClassNotFoundException e){
System.out.println(e);
}
}
Run Code Online (Sandbox Code Playgroud)
字体:http://www.jc-mouse.net/base-de-datos/consultas-con-parametros-en-access-y-java
我得到了这个错误:
[Microsoft] [ODBC Microsoft Access驱动程序]常规错误无法打开注册表项临时(易失性)Ace DSN进程0x7f8线程0x1174 DBC
特别
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]General error …
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
public class ImageAttachmentInDocument {
/**
* @param args
* @throws IOException
* @throws InvalidFormatException
*/
public static void main(String[] args) throws IOException, InvalidFormatException {
XWPFDocument doc = new XWPFDocument();
FileInputStream is = new FileInputStream("encabezado.jpg");
doc.addPictureData(IOUtils.toByteArray(is), doc.PICTURE_TYPE_JPEG);
XWPFParagraph title = doc.createParagraph();
XWPFRun run = title.createRun();
run.setText("Fig.1 A Natural Scene");
run.setBold(true);
title.setAlignment(ParagraphAlignment.CENTER);
FileOutputStream fos = new FileOutputStream("test4.docx");
doc.write(fos);
fos.flush();
fos.close();
}
}
Run Code Online (Sandbox Code Playgroud)
(我在eclipse IDE中使用Apache POI 3.11和xmlbeans-2.3.0)
当我生成文档时,不显示图像
我究竟做错了什么?