浏览:994 Java反射代码--04.得到指定的方法,并且执行此方法!

本文展示了如何使用Java反射API执行特定方法,包括加载类、获取方法、实例化对象并调用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2009-08-30 21:58 来自 漫步蓝色星球

/**
  * 4.得到指定的方法,并且执行此方法
  *
  */
 public void reflect4(){
    try {
       Class cls = Class.forName("entity.UserBean");//加载UserBean类到内存中!获取一个Class对象
       Method method = cls.getDeclaredMethod("getName");//根据方法名称得到对应的方法
       Object obj = cls.newInstance();//通过class类反射一个对象实体!
       Object value = method.invoke(obj);
       System.out.println(value);
    } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }
}

java.lang.reflect.InvocationTargetException: 从数据库中获取信息时发生错误: org.pentaho.di.core.exception.KettleDatabaseException: 因为错误不能提取数据库信息 Error getting views from schema [null] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('VIEW',null,null,null,null) ORDER BY TABLE_TYPE, TABLE_SCH' at line 1 at org.pentaho.di.ui.core.database.dialog.GetDatabaseInfoProgressDialog$1.run(GetDatabaseInfoProgressDialog.java:93) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 因为错误不能提取数据库信息 Error getting views from schema [null] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('VIEW',null,null,null,null) ORDER BY TABLE_TYPE, TABLE_SCH' at line 1 at org.pentaho.di.core.database.DatabaseMetaInformation.getData(DatabaseMetaInformation.java:413) at org.pentaho.di.ui.core.database.dialog.GetDatabaseInfoProgressDialog$1.run(GetDatabaseInfoProgressDialog.java:91) ... 1 more Caused by: org.pentaho.di.core.exception.KettleDatabaseException: Error getting views from schema [null] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('VIEW',null,null,null,null) ORDER BY TABLE_TYPE, TABLE_SCH' at line 1 at org.pentaho.di.core.database.Database.getViewMap(Database.java:4071) at org.pentaho.di.core.database.Database.getViews(Database.java:4000) at org.pentaho.di.core.database.Database.getViews(Database.java:3996) at org.pentaho.di.core.database.DatabaseMetaInformation.getData(DatabaseMetaInformation.java:379) ... 2 more Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('VIEW',null,null,null,null) ORDER BY TABLE_TYPE, TABLE_SCH' at line 1 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960) at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019) at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.executeMetadataQuery(DatabaseMetaDataUsingInfoSchema.java:62) at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.getTables(DatabaseMetaDataUsingInfoSchema.java:835) at org.pentaho.di.core.database.DatabaseInterface.getTables(DatabaseInterface.java:1287) at org.pentaho.di.core.database.DatabaseMeta.getTables(DatabaseMeta.java:3106) at org.pentaho.di.core.database.Database.getViewMap(Database.java:4034) ... 5 more
最新发布
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值