Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Source Code for Connector/J 8.0.31 - User Impl
Where to get the Java source code for Connector/J 8.0 User Impl module?
✍: FYIcenter.com
Java source code files for Connector/J 8.0 User Impl module are:
⏎ com/mysql/cj/xdevapi/TableImpl.java
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
* Free Software Foundation.
*
* This program is also distributed with certain software (including but not
* limited to OpenSSL) that is licensed under separate terms, as designated in a
* particular file or component or in included license documentation. The
* authors of MySQL hereby grant you an additional permission to link the
* program and your derivative works with the separately licensed software that
* they have included with MySQL.
*
* Without limiting anything contained in the foregoing, this file, which is
* part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
* version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.mysql.cj.xdevapi;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.mysql.cj.Messages;
import com.mysql.cj.MysqlxSession;
import com.mysql.cj.exceptions.MysqlErrorNumbers;
import com.mysql.cj.protocol.x.XMessage;
import com.mysql.cj.protocol.x.XMessageBuilder;
import com.mysql.cj.protocol.x.XProtocolError;
import com.mysql.cj.result.Row;
import com.mysql.cj.result.StringValueFactory;
import com.mysql.cj.result.ValueFactory;
/**
* {@link Table} implementation
*/
public class TableImpl implements Table {
private MysqlxSession mysqlxSession;
private SchemaImpl schema;
private String name;
private Boolean isView = null;
private XMessageBuilder xbuilder;
/* package private */ TableImpl(MysqlxSession mysqlxSession, SchemaImpl schema, String name) {
if (mysqlxSession == null) {
throw new XDevAPIError(Messages.getString("CreateTableStatement.0", new String[] { "mysqlxSession" }));
}
if (schema == null) {
throw new XDevAPIError(Messages.getString("CreateTableStatement.0", new String[] { "schema" }));
}
if (name == null) {
throw new XDevAPIError(Messages.getString("CreateTableStatement.0", new String[] { "name" }));
}
this.mysqlxSession = mysqlxSession;
this.xbuilder = (XMessageBuilder) this.mysqlxSession.<XMessage>getMessageBuilder();
this.schema = schema;
this.name = name;
}
public Session getSession() {
return this.schema.getSession();
}
public Schema getSchema() {
return this.schema;
}
public String getName() {
return this.name;
}
public DbObjectStatus existsInDatabase() {
if (this.mysqlxSession.getDataStoreMetadata().tableExists(this.schema.getName(), this.name)) {
return DbObjectStatus.EXISTS;
}
return DbObjectStatus.NOT_EXISTS;
}
public InsertStatement insert() {
return new InsertStatementImpl(this.mysqlxSession, this.schema.getName(), this.name, new String[] {});
}
public InsertStatement insert(String... fields) {
return new InsertStatementImpl(this.mysqlxSession, this.schema.getName(), this.name, fields);
}
public InsertStatement insert(Map<String, Object> fieldsAndValues) {
return new InsertStatementImpl(this.mysqlxSession, this.schema.getName(), this.name, fieldsAndValues);
}
@Override
public SelectStatement select(String... projection) {
return new SelectStatementImpl(this.mysqlxSession, this.schema.getName(), this.name, projection);
}
public UpdateStatement update() {
return new UpdateStatementImpl(this.mysqlxSession, this.schema.getName(), this.name);
}
public DeleteStatement delete() {
return new DeleteStatementImpl(this.mysqlxSession, this.schema.getName(), this.name);
}
public long count() {
try {
return this.mysqlxSession.getDataStoreMetadata().getTableRowCount(this.schema.getName(), this.name);
} catch (XProtocolError e) {
if (e.getErrorCode() == MysqlErrorNumbers.ER_NO_SUCH_TABLE) {
throw new XProtocolError("Table '" + this.name + "' does not exist in schema '" + this.schema.getName() + "'", e);
}
throw e;
}
}
@Override
public boolean equals(Object other) {
return other != null && other.getClass() == TableImpl.class && ((TableImpl) other).schema.equals(this.schema)
&& ((TableImpl) other).mysqlxSession == this.mysqlxSession && this.name.equals(((TableImpl) other).name);
}
@Override
public int hashCode() {
assert false : "hashCode not designed";
return 0;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Table(");
sb.append(ExprUnparser.quoteIdentifier(this.schema.getName()));
sb.append(".");
sb.append(ExprUnparser.quoteIdentifier(this.name));
sb.append(")");
return sb.toString();
}
@Override
public boolean isView() {
// if this.isView isn't set (was unknown on the table construction time) then query database
if (this.isView == null) {
ValueFactory<String> svf = new StringValueFactory(this.mysqlxSession.getPropertySet());
Function<Row, DatabaseObjectDescription> rowToDatabaseObjectDescription = r -> new DatabaseObjectDescription(r.getValue(0, svf),
r.getValue(1, svf));
List<DatabaseObjectDescription> objects = this.mysqlxSession.query(this.xbuilder.buildListObjects(this.schema.getName(), this.name), null,
rowToDatabaseObjectDescription, Collectors.toList());
if (objects.isEmpty()) {
// object not found, means it doesn't exist in database
return false;
}
// objects should contain exactly one element with matching this.name
this.isView = objects.get(0).getObjectType() == DbObjectType.VIEW || objects.get(0).getObjectType() == DbObjectType.COLLECTION_VIEW;
}
return this.isView;
}
/**
* Set flag indicating if the underlying object is a view.
*
* @param isView
* true if it is a View
*/
public void setView(boolean isView) {
this.isView = isView;
}
}
⏎ com/mysql/cj/xdevapi/TableImpl.java
Or download all of them as a single archive file:
File name: mysql-connector-java-user-impl-8.0.31.zip File size: 429580 bytes Release date: 2022-09-03 Download
⇒ Downloading mysql-connector-java-5.1.40.zip
⇐ Source Code for Connector/J 8.0.31 - User API
2023-05-09, ≈30🔥, 0💬
Popular Posts:
maven-compat-3.5.4.jar is the JAR file for Apache Maven 3.5.4 Compact module. The JAR file name may ...
The JSR 105 XML Digital Signature 1.0.1 FCS implementation provides an API and implementation that a...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...
The JDT project provides the tool plug-ins that implement a Java IDE supporting the development of a...
maven-embedder-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Embedder module. Apache Maven is a s...