在窗口7上安装了10g xe。我是jdbc和10g xe的新手。当使用一个简单的程序测试连接机智jdbc它工作正常,但当我尝试使用应用程序将一些数据存储到数据库时,它显示错误:ORA-12519:TNS:找不到合适的服务处理程序。当我通过互联网挖掘时,我发现lsnrctlr服务可能存在一些问题。我经历了这个网站上与ora-12519错误相关的其他帖子。但是没有帮助解决问题。请帮助。以下代码工作正常。没有任何错误或例外。
import java.sql.*;
public class OracleThinConnection {
public static void main(String args[]) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","tiger");
Statement stmt = con.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT * FROM emp");
while (rset.next ())
System.out.println (rset.getString (1));
rset.close();
stmt.close();
con.close();
System.out.println("Connected Successfully To Oracle");
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
但是当我执行以下代码时,它会显示ora-12519错误
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","tiger");
Statement s = con.createStatement ();
String str1=" create table " + s2.charAt(0) + "drive(fname varchar(256), fpath varchar(256), modifiedtime date,accesstime date,creationtime date,fsize numeric(20,0),owner varchar(256))"; //s2 is the drive name
System.out.println(str1);
s.execute(str1);
s.close();
con.close();
funInsertion(f[i],s2.charAt(0)+"drive"); // this function does the job of inserting the files in the drive to the corresponding drive table
}
catch(Exception e){ System.out.println("exception " +e);}
}
funInsertion()如下
public void funInsertion(File f,String s1){
String skip="";
try{
if(f.isDirectory()){
dir++;
File [] fi=f.listFiles();
for(int i=0;i<fi.length;i++){
if(fi[i].getName().equals("Program Files")){
skip=fi[i].getParent();
break;
}
}
for(int i=0;i<fi.length;i++){
if(fi[i].getAbsolutePath().equals(skip)){}
else
funInsertion(fi[i],s1);
}
}
else{
if(f.getAbsolutePath().equals(skip)){}
else{
files++;
Path file = Paths.get(f.getAbsolutePath());
BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","tiger");
Statement s = con.createStatement ();
s.execute("insert into " + s1 + " values('" + f.getName() + "','" + f.getAbsolutePath() + "','"+attrs.lastModifiedTime()+"','"+attrs.lastAccessTime()+"','"+attrs.creationTime()+"','"+attrs.size()+"','"+Files.getOwner(f.toPath())+"')");
s.close();
con.close();
}
catch(Exception e){ System.out.println("exception " +e);}
}
}
}
catch(Exception e){
}
}
当我检出lsnrctlr服务时显示以下消息