hadoop问题:连接postgresql数据库错误

天地一棵树 2014-11-19 10:26:27
主要main函数代码如下:
public static void main(String[] args) throws IOException, ClassNotFoundException {
// TODO Auto-generated method stub

JobConf conf = new JobConf(DBAccess.class);

conf.set("mapred.job.tracker","localhost:9101");

DBConfiguration.configureDB(conf, "org.postgresql.Driver","jdbc:postgresql://localhost:5433/xiaohe","pg","");

conf.setOutputKeyClass(LongWritable.class);
conf.setOutputValueClass(Text.class);

conf.setInputFormat(DBInputFormat.class);

String [] fields = {"id", "name", "age", "department"};

DBInputFormat.setInput(conf, TeacherRecord.class, "teacher",null, "id", fields);

FileOutputFormat.setOutputPath(conf, new Path("hdfs://localhost:9100/dbout"));

conf.setMapperClass(DBAccessMapper.class);
conf.setReducerClass(IdentityReducer.class);

JobClient.runJob(conf);

}
报错如下:
Exception in thread "main" java.lang.RuntimeException: Error in configuring object
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
at org.apache.hadoop.mapred.JobConf.getInputFormat(JobConf.java:400)
at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:810)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:781)
at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:730)
at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1249)
at testDB.DBAccess.main(DBAccess.java:49)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88)
... 8 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.postgresql.Driver
at org.apache.hadoop.mapred.lib.db.DBInputFormat.configure(DBInputFormat.java:271)
... 13 more
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.hadoop.mapred.lib.db.DBConfiguration.getConnection(DBConfiguration.java:123)
at org.apache.hadoop.mapred.lib.db.DBInputFormat.configure(DBInputFormat.java:266)
... 13 more


网上说配环境变量也配了,还是不行啊!!
...全文
3121 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
IBM云计算
创建于2010-12-16

1149

社区成员

该论坛主要探讨基于IBM云计算的开发技术,并为网友们提供自由交流的平台。
申请成为版主
帖子事件
创建了帖子
2014-11-19 10:26
社区公告
暂无公告