未找到适用于 ucanaccess 的驱动程序
Posted
技术标签:
【中文标题】未找到适用于 ucanaccess 的驱动程序【英文标题】:No suitable driver found for ucanaccess 【发布时间】:2019-03-28 12:59:22 【问题描述】:我有一个 .mdb 访问文件,我正在将数据索引到我的 solr 核心。我编写了这个 java 类来在 solr 核心中对它们进行索引。当我将这个 java 类作为 java 应用程序运行时,它可以正常工作,但是当我运行服务器端时,它就不起作用了。
package org.solr;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import java.applet.*;
import java.awt.*;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStreamBase.ByteArrayStream;
import org.apache.solr.handler.dataimport.DateFormatTransformer;
import org.apache.solr.schema.DateValueFieldType;
public class dbJava
public void main(String args[]) throws SolrServerException, IOException
Statement state;
Connection connect;
try
connect = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\FTK1187\\Desktop/eArchiveMaster.mdb","FTEC198","");
state = connect.createStatement();
ResultSet rs = state.executeQuery("SELECT * FROM TableArchive ORDER BY ID" );
//System.out.println(count);
String urlString="http://localhost:8983/solr/archiveCore";
HttpSolrClient solr=new HttpSolrClient.Builder(urlString).build();
((HttpSolrClient) solr).setParser(new XMLResponseParser());
//SolrInputDocument document=new SolrInputDocument();
final String contentStream = "extract this text ...";
final String contentType = "text/csv;charset=UTF-8";
final ByteArrayStream byteArrayStream = new ByteArrayStream(contentStream.getBytes(StandardCharsets.UTF_8), null);
byteArrayStream.setContentType(contentType);
final ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams();
modifiableSolrParams.add(CollectionAdminParams.COLLECTION, "archiveCore");
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
req.addContentStream(byteArrayStream);
req.setParams(modifiableSolrParams);
req.setMethod(METHOD.POST);
solr.deleteByQuery("*");
solr.commit();
long startTime=System.nanoTime();
while(rs.next())
req.setParam("literal.id", String.valueOf(rs.getInt("ID")));
req.setParam("literal.NameAdded", String.valueOf(rs.getString("NameAdded")));
req.setParam("literal.DateAdded", String.valueOf(rs.getString("DateAdded")));
req.setParam("literal.NameModified", String.valueOf(rs.getString("NameModified")));
req.setParam("literal.DateModified", String.valueOf(rs.getString("DateModified")));
req.setParam("literal.strSO", String.valueOf(rs.getString("strSO")));
req.setParam("literal.strCust", String.valueOf(rs.getString("strCust")));
req.setParam("literal.strOperator", String.valueOf(rs.getString("strOperator")));
req.setParam("literal.PackName", String.valueOf(rs.getString("PackName")));
req.setParam("literal.DocName", String.valueOf(rs.getString("DocName")));
req.setParam("literal.DocType", String.valueOf(rs.getString("DocType")));
req.setParam("literal.extType", String.valueOf(rs.getString("extType")));
req.setParam("literal.FileName", String.valueOf(rs.getString("FileName")));
req.setParam("literal.FilePath", String.valueOf(rs.getString("FilePath")));
req.setParam("literal.NameDeleted", String.valueOf(rs.getString("NameDeleted")));
req.setParam("literal.DateDeleted", String.valueOf(rs.getString("DateDeleted")));
req.setParam("literal.intRev", String.valueOf(rs.getString("intRev")));
solr.request(req);
long endTime=System.nanoTime();
long totalTime=endTime-startTime;
System.out.println("Done...");
System.out.println(totalTime);
String urlReload="http://localhost:8983/solr";
HttpSolrClient solr_reload=new HttpSolrClient.Builder(urlReload).build();
CoreAdminRequest adminRequest=new CoreAdminRequest();
adminRequest.setAction(CoreAdminAction.RELOAD);
adminRequest.setCoreName("archiveCore");
adminRequest.process(solr_reload);
catch(IOException e)
e.printStackTrace();
catch (SQLException e)
// TODO Auto-generated catch block
e.printStackTrace();
我想使用 jquery 在 my.jsp 页面中运行这个 java 类。当我单击更新按钮时,它给了我这个错误。
java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:\Users\FTK1187\Desktop/eArchiveMaster.mdb
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.solr.dbJava.main(dbJava.java:60)
at org.apache.jsp.upload_jsp._jspService(upload_jsp.java:124)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
有什么错误吗??如何在我的 .jsp 文件中调用 java 类?
【问题讨论】:
【参考方案1】:你必须在 JRE/lib/ext 中移动 Driver
【讨论】:
以上是关于未找到适用于 ucanaccess 的驱动程序的主要内容,如果未能解决你的问题,请参考以下文章
当 Jackcess 连接正常时,UCanAccess 驱动程序在尝试连接 Access 数据库时抛出异常
在 NetBeans 中导出 maven 项目后找不到 Ucanaccess 驱动程序