Java SQL Blob getLongBlobTypeString(Connection conn)

Here you can find the source of getLongBlobTypeString(Connection conn)

Description

get Long Blob Type String

License

Open Source License

Declaration

public static String getLongBlobTypeString(Connection conn) 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave.// w w  w.jav a  2s. com
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * ***** END LICENSE BLOCK ***** */

import java.sql.Connection;

import java.sql.SQLException;

public class Main {
    public static String MYSQL = "MySQL";
    public static String SQLITE = "SQLite";
    public static String POSTGRESQL = "PostgreSQL";
    public static String SQLSERVER = "Microsoft SQL Server";
    public static String ORACLE = "Oracle";

    public static String getLongBlobTypeString(Connection conn) {
        if (isOracleServer(conn))
            return "BLOB";
        return "LONGBLOB";
    }

    /**
     * This function checks if a connection is for an Oracle server.
     * @param conn A SQL Connection.
     * @return A value of true if the Connection is for an Oracle server.
     * @throws SQLException 
     */
    public static boolean isOracleServer(Connection conn) {
        return getDbmsFromConnection(conn).equals(ORACLE);
    }

    public static String getDbmsFromConnection(Connection conn) {
        try {
            String dbms = conn.getMetaData().getDatabaseProductName();
            for (String match : new String[] { ORACLE, SQLSERVER, MYSQL,
                    SQLITE, POSTGRESQL })
                if (dbms.equalsIgnoreCase(match))
                    return match;
            return dbms;
        } catch (SQLException e) {
            return "";
        }
    }
}

Related

  1. blobToBytes(Blob blob)
  2. getAsString(Blob blob)
  3. getBlobType(byte[] image)
  4. getDataFromBlob(Blob b)
  5. getDataFromBlob(Blob b)
  6. getString(Blob blob)
  7. getStringValue(Blob blob)
  8. isBlob(Object object)
  9. readBlob(Blob blob)