我有一个.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类?
答案 0 :(得分:0)
您必须在JRE / lib / ext中移动驱动程序