Esempio n. 1
0
		/// <summary>
		/// 在rs中获取column字段的typeClass型的值
		/// </summary>
		/// <param name="rs"> </param>
		/// <param name="column"> </param>
		/// <param name="paramClass">
		/// 
		/// @return
		/// </param>
		/// <exception cref="SQLException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static Object getValue4Type(java.sql.ResultSet rs, String column, Class typeClass) throws java.sql.SQLException
		public static object getValue4Type(ResultSet rs, string column, Type typeClass)
		{

			if (typeClass.IsSubclassOf(typeof(ICollection)))
			{
				return null;
			}

			try
			{
				rs.findColumn(column);
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
				return null;
			}

			if (typeClass.Equals(typeof(Integer)) || typeClass.Equals(Integer.TYPE))
			{
				return rs.getInt(column);
			}

			if (typeClass.Equals(typeof(Long)) || typeClass.Equals(Long.TYPE))
			{
				return rs.getLong(column);
			}

			if (typeClass.Equals(typeof(Boolean)) || typeClass.Equals(Boolean.TYPE))
			{
				return rs.getBoolean(column);
			}

			if (typeClass.Equals(typeof(Float)) || typeClass.Equals(Float.TYPE))
			{
				return rs.getFloat(column);
			}

			if (typeClass.Equals(typeof(Double)) || typeClass.Equals(Double.TYPE))
			{
				return rs.getDouble(column);
			}

			if (typeClass.Equals(typeof(Byte)) || typeClass.Equals(Byte.TYPE))
			{
				return rs.getByte(column);
			}

			if (typeClass.Equals(typeof(string)))
			{
				return rs.getString(column);
			}

			if (typeClass.IsSubclassOf(typeof(DateTime)))
			{
				return rs.getTimestamp(column);
			}

			if (typeClass.IsSubclassOf(typeof(java.sql.Date)))
			{
				return rs.getDate(column);
			}

			return rs.getObject(column);
		}