It's also most up-to-date resource and covers changes on recent Java versions up to Java Without wasting any more time, here is the list of some of the great Java books, which are absolutely FREE, you don't need to pay anything to download or read this book.
All you need is an internet connection to download these books on your computer, laptop, iPhone, or Android smartphone. Many Thanks to O'Rilley who has published an introductory book on Java 8, titled with Introducing Java 8, A quick start guide to lambda expressions and streams.
The author Raoul-Gabriel Urma, who is also an author of one of the best seller book of last year, Java 8 in Action , explains how improved code readability and support for multicore processors were the prime movers behind Java 8 features. Along with books, there are a lot of free courses to learn Data Structure and Algorithms.
I have done some hard work and also published a list of my favorite Free Data Structure and Algorithms courses you should also check them to learn this important topic better. It's completely free. You can download entire books as PDF, along with all example programs. Carl Albing and Michael Schwarz have done an excellent job to put everything needed to run and support a Java program in Linux environment including how to start, stop, or kill Java process, checking logs with some handy useful UNIX commands.
Paperback edition of this book is also available here on Amazon. Paperback edition of this Java book is also available for purchase on Amazon, here. Labels: books , core java , free resources , programming. Shivam June 2, at AM.
Unknown August 25, at AM. Unknown August 31, at AM. Unknown February 11, at AM. Anonymous April 6, at AM. Unknown May 3, at AM. The warning may indicate that a fetch loop terminated early, perhaps due to an uncaught error. To avoid the warning call the finish method on the active handles. Attempts to determine, in a reasonably efficient way, if the database server is still running and the connection to it is still working. Individual drivers should implement this function in the most suitable manner for their database engine.
The current default implementation always returns true without actually doing anything. Actually, it returns " 0 but true " which is true but zero.
That way you can tell if the return value is genuine or just the default. Drivers should override this method with one that does the right thing for their type of database. Few applications would have direct use for this method. See the specialized Apache::DBI module for one example usage.
Returns information about the implementation, i. It returns undef for unknown or unimplemented information types. See "Standards Reference Information" for more detailed information about the information types and their meanings and possible return values.
Values in that range which have been assigned a meaning are defined here:. The backslash will be removed before the text is passed to the backend. Returns an active statement handle that can be used to fetch information about tables and views that exist in the database. Each value may optionally be quoted, e. If your driver doesn't support one or more of the selection filter parameters then you may get back more than you asked for and can do the filtering yourself.
This method can be expensive, and can return a large amount of data. For example, small Oracle installation returns over rows. So it's a good idea to use the filters to limit the data as much as possible. The statement handle returned has at least the following fields in the order show below. Other fields, after these, may also be present.
This field is NULL undef if not applicable to the data source, which is usually the case. This field is empty if not applicable to the table. This field is NULL undef if not applicable to data source, and empty if not applicable to the table. Returns an active statement handle that can be used to fetch information about columns in specified tables.
Note: The support for the selection criteria is driver specific. If the driver doesn't support one or more of them then you may get back more than you asked for and can do the filtering yourself. If the arguments don't match any tables then you'll still get a statement handle, it'll just return no rows. The statement handle returned has at least the following fields in the order shown below.
This field is NULL undef if not applicable to the data source, which is often the case. This field is NULL undef if not applicable to the data source, and empty if not applicable to the table. This is the maximum length in characters for character data types, the number of digits or bits for numeric data types or the length in the representation of temporal types.
See the relevant specifications for detailed information. The value is 10 or 2 for numeric data types and NULL undef if not applicable. For example, given:. Drivers capable of supplying any of those values should do so in the corresponding column and supply undef values for the others.
Applications accessing such fields should do so by name and not by column number. However, SQLColumns provides more metadata. Returns an active statement handle that can be used to fetch information about columns that make up the primary key for a table.
If there is no primary key then the statement handle will fetch no rows. This field is NULL undef if not applicable to the data source. Returns a list of the column names that comprise the primary key of the specified table. The list is in primary key column sequence order.
If there is no primary key then an empty list is returned. If only PKT is given, then the result set contains the primary key of that table and all foreign keys that refer to it. If only FKT is given, then the result set contains all foreign keys in that table and the primary keys to which they refer. The statement handle returned has the following fields in the order shown below. The following codes are defined:. Returns an active statement handle that can be used to fetch statistical information about a table and its indexes.
Some databases may return stale statistics or no statistics at all with this flag set. Returns 0 for unique indexes, 1 for non-unique indexes. TYPE : The type of information being returned. Can be any of the following values: 'table', 'btree', 'clustered', 'content', 'hashed', or 'other'. For indexes, this is the number of unique values in the index. For tables, this is the number of rows in the table. If not supported, the value will be NULL undef. If the index is not a filtered index, or it cannot be determined whether the index is a filtered index, this value is NULL undef.
If the index is a filtered index, but the filter condition cannot be determined, this value is the empty string ''. This means that the table names returned will include quote characters. Returns a reference to an array which holds information about each data type variant supported by the database and driver. The array and its contents should be treated as read-only. The items following that are references to arrays, one per supported data type variant.
The leading index hash defines the names and order of the fields within the arrays that follow it. An 'index' hash is provided so you don't need to rely on index values defined above. Another issue with the index hash is that the lettercase of the keys is not defined.
It is usually uppercase, as show here, but drivers may return names with any lettercase. If called in a scalar context then only the first best element is returned. The following uppercase items should always exist, though may be undef:.
For date and interval types, this is the maximum number of characters needed to display the value. Characters used to prefix a literal. A typical prefix is " ' " for characters, or possibly " 0x " for binary values passed as hexadecimal. NULL undef is returned for data types for which this is not applicable.
Characters used to suffix a literal. Typically " ' " for characters. NULL undef is returned for data types where this is not applicable. Parameter names for data type definition. Indicates whether the data type is unsigned.
Indicates whether the data type always has the same precision and scale such as a money type. Indicates whether a column of this data type is automatically set to a unique value whenever a new row is inserted. The minimum scale of the data type. The maximum scale of the data type. If this field is NULL, then the driver does not support or report on interval or datetime subtypes. Otherwise it will be NULL undef. Although not mentioned explicitly in the standards, it seems there is a simple relationship between these values:.
The radix value of the data type. NULL undef is returned either for data types for which this is not applicable or if the driver cannot report this information. The interval leading precision for interval types. NULL is returned either for data types for which this is not applicable or if the driver cannot report this information.
Here's an example looking for a usable type to store a date:. See also "Standards Reference Information". Quote a string literal for use as a literal value in an SQL statement, by escaping any special characters such as quotation marks contained within the string and adding the required type of outer quotation marks.
For most database types, at least those that conform to SQL standards, quote would return 'Don''t' including the outer quotation marks. Quote will probably not be able to deal with all possible input such as binary data or data containing newlines , and is not related in any way with escaping or quoting shell meta-characters.
It is valid for the quote method to return an SQL expression that evaluates to the desired string. The quote method should not be used with "Placeholders and Bind Values".
Quote an identifier table name etc. Undefined names are ignored and the remainder are quoted and then joined together, typically with a dot. For example, for Oracle:. Why would you want to do this?
You don't, forget I even mentioned it. Unless, that is, you're implementing something advanced like a multi-threaded connection pool. See DBI::Pool. Don't do that. Changes to these database handle attributes do not affect any other existing or future database handles. Attempting to set or get the value of an unknown attribute generates a warning, except for private driver-specific attributes which all have names starting with a lowercase letter.
If true, then database changes cannot be rolled-back undone. If false, then database changes automatically occur within a "transaction", which must either be committed or rolled back using the commit or rollback methods.
Attempting to set AutoCommit to an unsupported value is a fatal error. This is an important feature of the DBI. For these databases, attempting to turn AutoCommit off is a fatal error. These are typically mainstream commercial relational databases with "ANSI standard" transaction behaviour. If AutoCommit is off, then changes to the database won't have any lasting effect unless "commit" is called but see also "disconnect".
If "rollback" is called then any changes since the last commit are undone. If AutoCommit is on, then the effect is the same as if the DBI called commit automatically after every successful database operation.
So calling commit or rollback explicitly while AutoCommit is on would be ineffective because the changes would have already been committed. Changing AutoCommit from off to on will trigger a "commit".
The error information reported to the application will correspond to the statement which was executed, unless it succeeded and the commit or rollback failed.
For these databases, the intention is to have them act like databases in which a transaction is always active as described above. To do this, the driver will automatically begin an explicit transaction when AutoCommit is turned off, or after a "commit" or "rollback" or when the application issues the next database operation after one of those events.
See "commit" , "disconnect" and "Transactions" for other important notes about transactions. Holds the handle of the parent driver. The only recommended use for this is to find the name of the driver using:. Holds the "name" of the database.
Usually and recommended to be the same as the " dbi:DriverName Returns the statement string passed to the most recent "prepare" or "do" method called in this database handle, even if that method failed.
A hint to the driver indicating the size of the local row cache that the application would like the driver to use for future SELECT statements. If a row cache is not implemented, then setting RowCacheSize is ignored and getting the value returns undef. Also, a large cache will cause a longer delay not only for the first fetch, but also whenever the cache needs refilling. Placeholders are indicated with question mark character?
See "Placeholders and Bind Values" for more information. This is rarely needed. Typically, the driver is only interested in knowing if the placeholder should be bound as a number or a string. This example is equivalent to the one above:. The TYPE value indicates the standard non-driver-specific type for this parameter. Perl only has string and number scalar data types. You can then use an SQL function to convert the type within the statement.
The actual function and syntax will vary between different databases and is non-portable. See also "Placeholders and Bind Values" for more information. The statement is typically a call to a stored procedure. Instead, the value in the variable is read at the time "execute" is called.
If the value returned from the database is too big to fit, then the execution should fail. If unsure what value to use, pick a generous length, i. The only cost of using a larger value than needed is wasted memory.
Undefined values or undef are used to indicate null values. A placeholder can only ever represent one value per execution. In which case the same value will be used for each "execute" call. Driver-specific implementations may behave differently, e. The default implementation provided by DBI for drivers that have not implemented array binding is to iteratively call "execute" for each parameter tuple provided in the bound arrays.
Drivers may provide more optimized implementations using whatever bulk operation support the database API provides. The default driver behaviour should match the default DBI behaviour, but always consult your driver documentation as there may be driver specific issues to consider. Perform whatever processing is necessary to execute the prepared statement. An undef is returned if an error occurs.
A successful execute always returns true regardless of the number of rows affected, even if it's zero see below. It is always important to check the return status of execute and most other DBI methods for errors if you're not using "RaiseError". If no rows were affected, then execute returns " 0E0 ", which Perl will treat as 0 but will regard as true.
Note that it is not an error for no rows to be affected by a statement. If the number of rows affected is not known, then execute returns Use one of the fetch methods to retrieve the data after calling execute.
The execute method does not return the number of rows that will be returned by the query because most databases can't tell in advance , it simply returns a true value. Note that passing execute an empty array is the same as passing no arguments at all, which will execute the statement with previously bound values.
That's probably not what you want. If there were any errors the ArrayTupleStatus array can be used to discover which tuples failed and with what errors. NOTE, some drivers cannot determine the number of rows affected per tuple but can provide the number of rows affected for the batch. If you are doing an update operation the returned rows affected may not be what you expect if, for instance, one or more of the tuples affected the same row multiple times.
Placeholders with fewer values in their parameter arrays are treated as if padded with undef NULL values. If a scalar value is bound, instead of an array reference, it is treated as a variable length array with all elements having the same value. It does not influence the number of tuples executed, so if all bound arrays have zero elements then zero tuples will be executed.
The ArrayTupleFetch attribute can be used to specify a reference to a subroutine that will be called to provide the bind values for each tuple execution. The subroutine should return an reference to an array which contains the appropriate number of bind values, or return an undef if there is no more data to execute. As a convenience, the ArrayTupleFetch attribute can also be used to specify a statement handle.
The ArrayTupleStatus attribute can be used to specify a reference to an array which will receive the execute status of each executed parameter tuple. For tuples which are successfully executed, the element at the same ordinal position in the status array is the resulting rowcount or -1 if unknown.
If the execution of a tuple causes an error, then the corresponding status array element will be set to a reference to an array containing "err" , "errstr" and "state" set by the failed execution. In that case, the application should inspect the status array to determine which parameter tuples failed. Some databases may not continue executing tuples beyond the first failure. In this case the status array will either hold fewer elements, or the elements beyond the failure will be undef.
At present, the default implementation provided by DBI only supports non-data returning statements. Transaction semantics when using array binding are driver and database specific. If AutoCommit is on, the default DBI implementation will cause each parameter tuple to be individually committed or rolled back in the event of an error. If AutoCommit is off, the application is responsible for explicitly committing the entire set of bound parameter tuples.
Note that different drivers and databases may have different behaviours when some parameter tuples cause failures. In some cases, the driver or database may automatically rollback the effect of all prior parameter tuples that succeeded in the transaction; other drivers or databases may retain the effect of prior successfully executed parameter tuples.
Be sure to check your driver and database for its specific behaviour. If the corresponding execute did not fail then the element holds the return value from execute , which is typically a row count. Drivers are free to accumulate sets of tuples to pass to the database server in bulk group operations for more efficient execution. Similarly, if you already have an array containing the data rows to be processed you'd use a subroutine to shift off and return each array ref in turn:. Fetches the next row of data and returns a reference to an array holding the field values.
Null fields are returned as undef values in the array. Note that the same array reference is returned for each fetch, so don't store the reference and then use it after a later fetch. Also, the elements of the array are also reused for each row, so take care if you want to take a reference to an element. Fetches the next row of data and returns it as a list containing the field values.
Null fields are returned as undef values in the list. Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs.
Null fields are returned as undef values in the hash. By default a reference to a new hash is returned for each row. It is likely that a future version of the DBI will support an attribute which will enable the same hash to be reused for each row. This will give a significant performance boost, but it won't be enabled by default because of the risk of breaking old code. It returns a reference to an array that contains one reference per row. See "FetchHashKeyName" attribute.
The values of the hash should be set to 1. The key names of the returned hashes match the letter case of the names in the parameter hash, regardless of the "FetchHashKeyName" attribute. To fetch only the fields called "foo" and "bar" of every row as a hash ref with keys named "foo" and "BAR", regardless of the original capitalization :. The keys are 0-based column index numbers and the values are the corresponding keys for the returned row hashes.
For example, to fetch only the first and second columns of every row as a hash ref with keys named "k" and "v" regardless of their original names :. That might be the fastest way to fetch and process lots of rows using the DBI, but it depends on the relative cost of method calls vs memory allocation.
A standard while loop with column binding is often faster because the cost of allocating memory for the batch of rows is greater than the saving by reducing method calls. If multiple rows are returned with the same values for the key fields then later rows overwrite earlier ones. Indicate that no more data will be fetched from this statement handle before it is either executed again or destroyed. You almost certainly do not need to call this method.
Adding calls to finish after loop that fetches all rows is a common mistake, don't do it, it can mask genuine problems like uncaught fetch errors. So you should not call it explicitly except when you know that you've not fetched all the data from a statement handle and the handle won't be destroyed soon.
When executed, the database server will have to use temporary buffer space to store the sorted rows. If, after executing the handle and selecting just a few rows, the handle won't be re-executed for some time and won't be destroyed, the finish method can be used to tell the server that the buffer space can be freed. Calling finish resets the "Active" attribute for the statement. The finish method does not affect the transaction status of the database connection.
It has nothing to do with transactions. It's mostly an internal "housekeeping" method that is rarely needed. See also "disconnect" and the "Active" attribute. Returns the number of rows affected by the last row affecting command, or -1 if the number of rows is not known or not available. For SELECT statements, it is generally not possible to know how many rows will be returned except by fetching them all. Some drivers will return the number of rows the application has fetched so far, but others may return -1 until all rows have been fetched.
Column numbers count up from 1. You do not need to bind output columns in order to fetch data. The binding is performed at a low level using Perl aliasing. This makes using bound variables very efficient. Binding a tied variable doesn't work, currently.
For example, you can use:. Fewer still allow the data type to be altered once set. From DBI 1. If the bound value cannot be cast to the requested TYPE then by default it is left untouched and no error is generated. If you specify StrictlyTyped as 1 and the cast fails, this will generate an error. This attribute was first added in DBI 1. When 1. By default, DiscardString is not set. For compatibility with old scripts, the first parameter will be ignored if it is undef or a hash reference.
Here's a more fancy example that binds columns to the values inside a hash thanks to H. Merijn Brand :. This method is designed as a handy utility for prototyping and testing queries. This section describes attributes specific to statement handles. Most of these attributes are read-only. Changes to these statement handle attributes do not affect any other existing or future statement handles.
Typically the attribute will be undef in these situations. See also "finish" to learn more about the effect it may have on some attributes. With interactive learning, teams get hands-on experience with tech like Kubernetes, Python, Docker, Java, and more—in safe live dev environments.
Anyone can use a search engine. But can they trust what they find? So they find trusted solutions they can put to work immediately. Your teams have access to nearly 1, live online courses and events every year, led by top experts in AI, software architecture, cloud, data, programming, and more.
And they can ask questions along the way. Radar Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology. Future of the Firm Everything from new organizational structures and payment schemes to new expectations, skills, and tools will shape the future of the firm.
0コメント